Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.cc

Issue 10804012: Add native Windows binary for gperf. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.cc
===================================================================
--- gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.cc (revision 0)
+++ gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.cc (revision 0)
@@ -0,0 +1,177 @@
+/* A set of byte positions.
+ Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
+ Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
+ and Bruno Haible <bruno@clisp.org>.
+
+ This file is part of GNU GPERF.
+
+ GNU GPERF is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU GPERF is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Specification. */
+#include "positions.h"
+
+#include <stdio.h>
+#include <stdlib.h> /* declares exit() */
+#include <string.h>
+
+/* ---------------------------- Class Positions ---------------------------- */
+
+/* Set operations. Assumes the array is in reverse order. */
+
+bool
+Positions::contains (int pos) const
+{
+ unsigned int count = _size;
+ const int *p = _positions + _size - 1;
+
+ for (; count > 0; p--, count--)
+ {
+ if (*p == pos)
+ return true;
+ if (*p > pos)
+ break;
+ }
+ return false;
+}
+
+void
+Positions::add (int pos)
+{
+ set_useall (false);
+
+ unsigned int count = _size;
+
+ if (count == MAX_SIZE)
+ {
+ fprintf (stderr, "Positions::add internal error: overflow\n");
+ exit (1);
+ }
+
+ int *p = _positions + _size - 1;
+
+ for (; count > 0; p--, count--)
+ {
+ if (*p == pos)
+ {
+ fprintf (stderr, "Positions::add internal error: duplicate\n");
+ exit (1);
+ }
+ if (*p > pos)
+ break;
+ p[1] = p[0];
+ }
+ p[1] = pos;
+ _size++;
+}
+
+void
+Positions::remove (int pos)
+{
+ set_useall (false);
+
+ unsigned int count = _size;
+ if (count > 0)
+ {
+ int *p = _positions + _size - 1;
+
+ if (*p == pos)
+ {
+ _size--;
+ return;
+ }
+ if (*p < pos)
+ {
+ int prev = *p;
+
+ for (;;)
+ {
+ p--;
+ count--;
+ if (count == 0)
+ break;
+ if (*p == pos)
+ {
+ *p = prev;
+ _size--;
+ return;
+ }
+ if (*p > pos)
+ break;
+ int curr = *p;
+ *p = prev;
+ prev = curr;
+ }
+ }
+ }
+ fprintf (stderr, "Positions::remove internal error: not found\n");
+ exit (1);
+}
+
+/* Output in external syntax. */
+void
+Positions::print () const
+{
+ if (_useall)
+ printf ("*");
+ else
+ {
+ bool first = true;
+ bool seen_LASTCHAR = false;
+ unsigned int count = _size;
+ const int *p = _positions + _size - 1;
+
+ for (; count > 0; p--)
+ {
+ count--;
+ if (*p == LASTCHAR)
+ seen_LASTCHAR = true;
+ else
+ {
+ if (!first)
+ printf (",");
+ printf ("%d", *p + 1);
+ if (count > 0 && p[-1] == *p + 1)
+ {
+ printf ("-");
+ do
+ {
+ p--;
+ count--;
+ }
+ while (count > 0 && p[-1] == *p + 1);
+ printf ("%d", *p + 1);
+ }
+ first = false;
+ }
+ }
+ if (seen_LASTCHAR)
+ {
+ if (!first)
+ printf (",");
+ printf ("$");
+ }
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+#ifndef __OPTIMIZE__
+
+#define INLINE /* not inline */
+#include "positions.icc"
+#undef INLINE
+
+#endif /* not defined __OPTIMIZE__ */
Property changes on: gperf\src\gperf\3.0.1\gperf-3.0.1-src\src\positions.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.h ('k') | gperf/src/gperf/3.0.1/gperf-3.0.1-src/src/positions.icc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698