[GRASS-SVN] r40838 - in grass/trunk: include lib/gis lib/sites
lib/vector/Vlib lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 5 21:42:45 EST 2010
Author: glynn
Date: 2010-02-05 21:42:44 -0500 (Fri, 05 Feb 2010)
New Revision: 40838
Removed:
grass/trunk/lib/gis/index.c
Modified:
grass/trunk/include/gisdefs.h
grass/trunk/lib/gis/parser_help.c
grass/trunk/lib/gis/token.c
grass/trunk/lib/sites/sites.c
grass/trunk/lib/vector/Vlib/ascii.c
grass/trunk/lib/vector/Vlib/header.c
grass/trunk/lib/vector/diglib/frmt.c
Log:
Eliminate G_index(), G_rindex(); replace with strchr(), strrchr()
Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/include/gisdefs.h 2010-02-06 02:42:44 UTC (rev 40838)
@@ -286,10 +286,6 @@
const char *G_home(void);
const char *G__home(void);
-/* index.c */
-char *G_index(const char *, int);
-char *G_rindex(const char *, int);
-
/* intersect.c */
int G_intersect_line_segments(double, double, double, double, double, double,
double, double, double *, double *, double *,
Deleted: grass/trunk/lib/gis/index.c
===================================================================
--- grass/trunk/lib/gis/index.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/gis/index.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -1,49 +0,0 @@
-/* TODO: should this go into strings.c ? */
-
-#include <grass/gis.h>
-
-
-/*!
- * \brief delimiter
- *
- * position of delimiter
- *
- * \param str
- * \param delim
- * \return char *
- */
-
-char *G_index(const char *str, int delim)
-{
- while (*str && *str != delim)
- str++;
- if (delim == 0)
- return (char *)str;
- return *str ? (char *)str : NULL;
-}
-
-
-/*!
- * \brief ???
- *
- * ???
- *
- * \param str
- * \param delim
- * \return char *
- */
-
-char *G_rindex(const char *str, int delim)
-{
- const char *p;
-
- p = NULL;
- while (*str) {
- if (*str == delim)
- p = str;
- str++;
- }
- if (delim == 0)
- return (char *)str;
- return (char *)p;
-}
Modified: grass/trunk/lib/gis/parser_help.c
===================================================================
--- grass/trunk/lib/gis/parser_help.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/gis/parser_help.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -218,7 +218,7 @@
fprintf(stderr, _(" %*s options: "), maxlen, " ");
totlen = maxlen + 13;
p1 = buff;
- while ((p2 = G_index(p1, ','))) {
+ while ((p2 = strchr(p1, ','))) {
*p2 = '\0';
len = strlen(p1) + 1;
if ((len + totlen) > 76) {
Modified: grass/trunk/lib/gis/token.c
===================================================================
--- grass/trunk/lib/gis/token.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/gis/token.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -15,6 +15,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include <grass/gis.h>
@@ -49,7 +50,7 @@
char *p;
i = 0;
- while (!G_index(delim, *buf) && (*buf == ' ' || *buf == '\t')) /* needed for G_free () */
+ while (!strchr(delim, *buf) && (*buf == ' ' || *buf == '\t')) /* needed for G_free () */
buf++;
p = G_store(buf);
@@ -57,14 +58,14 @@
tokens = (char **)G_malloc(sizeof(char *));
while (1) {
- while (!G_index(delim, *p) && (*p == ' ' || *p == '\t'))
+ while (!strchr(delim, *p) && (*p == ' ' || *p == '\t'))
p++;
if (*p == 0)
break;
tokens[i++] = p;
tokens = (char **)G_realloc((char *)tokens, (i + 1) * sizeof(char *));
- while (*p && (G_index(delim, *p) == NULL))
+ while (*p && (strchr(delim, *p) == NULL))
p++;
if (*p == 0)
break;
Modified: grass/trunk/lib/sites/sites.c
===================================================================
--- grass/trunk/lib/sites/sites.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/sites/sites.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -632,9 +632,9 @@
}
/* move pointer past easting and northing fields */
- if (NULL == (buf = G_index(buf, PIPE)))
+ if (NULL == (buf = strchr(buf, PIPE)))
return -2;
- if (NULL == (buf = G_index(buf + 1, PIPE)))
+ if (NULL == (buf = strchr(buf + 1, PIPE)))
return -2;
/* check for remaining dimensional fields */
@@ -647,13 +647,13 @@
if (sscanf(buf, "%lf|", &(s->dim[dim++])) < 1)
return -2; /* no more dims, though expected */
}
- else if (NULL != (p1 = G_index(buf, PIPE))) {
- if (NULL == (p2 = G_index(buf, DQUOTE)))
+ else if (NULL != (p1 = strchr(buf, PIPE))) {
+ if (NULL == (p2 = strchr(buf, DQUOTE)))
err = 1; /* more dims, though none expected */
else if (strlen(p1) > strlen(p2))
err = 1; /* more dims, though none expected */
}
- } while ((buf = G_index(buf, PIPE)) != NULL);
+ } while ((buf = strchr(buf, PIPE)) != NULL);
buf = last;
/* no more dimensions-now we parse attribute fields */
@@ -803,7 +803,7 @@
}
/* check for remaining dimensional fields */
- while (G_index(buf, PIPE) != (char *)NULL) {
+ while (strchr(buf, PIPE) != (char *)NULL) {
(*dims)++;
while (!ispipe(*buf) && !isnull(*buf))
buf++;
@@ -920,7 +920,7 @@
/* find where this string terminates */
if (*buf != DQUOTE) { /* if no DQUOTEs, */
- stop = G_index(buf, SPACE); /* then SPACE separates */
+ stop = strchr(buf, SPACE); /* then SPACE separates */
if (stop == (char *)NULL)
return strlen(buf);
else
@@ -935,14 +935,14 @@
p++;
}
p = buf;
- stop = G_index(p + 1, DQUOTE);
+ stop = strchr(p + 1, DQUOTE);
while (*(stop - 1) == BSLASH)
- stop = G_index(++stop, DQUOTE);
+ stop = strchr(++stop, DQUOTE);
}
}
/* remove backslashes between buf and stop */
p = buf;
- while ((p = G_index(p, BSLASH)) != (char *)NULL && p <= stop) {
+ while ((p = strchr(p, BSLASH)) != (char *)NULL && p <= stop) {
p2 = p + 1;
if (*p2 != '\0' && (*p2 == DQUOTE || *p2 == BSLASH)) {
while (*p != '\0') {
@@ -1102,7 +1102,7 @@
/* do not uncomment this code because sites file was created
* as we want. So it's enough to print them out as it is.
*
- if (G_index (s->str_att[i], DQUOTE) != (char *) NULL)
+ if (strchr (s->str_att[i], DQUOTE) != (char *) NULL)
{
while (!isnull(s->str_att[i][j]))
{
@@ -1124,7 +1124,7 @@
strcpy(s->str_att[i], xbuf);
- if (G_index(s->str_att[i], SPACE) != (char *)NULL)
+ if (strchr(s->str_att[i], SPACE) != (char *)NULL)
sprintf(xbuf, "%s%s\"%s\"", nfs, ((id == 0) ? "" : "@"),
s->str_att[i]);
else
Modified: grass/trunk/lib/vector/Vlib/ascii.c
===================================================================
--- grass/trunk/lib/vector/Vlib/ascii.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/vector/Vlib/ascii.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -14,6 +14,7 @@
\author Updated for GRASS 7 (SF support) by Martin Landa <landa.martin gmail.com>
*/
#include <stdio.h>
+#include <string.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
@@ -217,7 +218,7 @@
if (strncmp(buff, "VERTI:", 6) == 0)
return (0);
- if (!(ptr = G_index(buff, ':')))
+ if (!(ptr = strchr(buff, ':')))
G_fatal_error(_("Unexpected data in vector head:\n[%s]"), buff);
ptr++; /* Search for the start of text */
Modified: grass/trunk/lib/vector/Vlib/header.c
===================================================================
--- grass/trunk/lib/vector/Vlib/header.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/vector/Vlib/header.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -143,7 +143,7 @@
while (G_getl2(buff, 2000, head_fp)) {
- if (!(ptr = G_index(buff, ':'))) {
+ if (!(ptr = strchr(buff, ':'))) {
G_warning(_("Corrupted row in head: %s"), buff);
continue;
}
Modified: grass/trunk/lib/vector/diglib/frmt.c
===================================================================
--- grass/trunk/lib/vector/diglib/frmt.c 2010-02-06 02:37:43 UTC (rev 40837)
+++ grass/trunk/lib/vector/diglib/frmt.c 2010-02-06 02:42:44 UTC (rev 40838)
@@ -41,7 +41,7 @@
if (G_getl2(buff, 2000, dascii)) {
G_chop(buff);
- if (!(ptr = G_index(buff, ':'))) {
+ if (!(ptr = strchr(buff, ':'))) {
G_warning("Vector format not recognized: %s", buff);
return (-1);
}
@@ -73,7 +73,7 @@
while (G_getl2(buff, 2000, dascii)) {
G_chop(buff);
- if (!(ptr = G_index(buff, ':'))) {
+ if (!(ptr = strchr(buff, ':'))) {
G_warning("Format definition is not correct: %s", buff);
continue;
}
More information about the grass-commit
mailing list