parser/inpgtok.c, use copy_substring()
This commit is contained in:
parent
39d391fe33
commit
2cbc84ccd1
|
|
@ -30,7 +30,6 @@ INPgetTok(char **line, char **token, int gobble)
|
||||||
{
|
{
|
||||||
char *point;
|
char *point;
|
||||||
int signstate;
|
int signstate;
|
||||||
int diffpoints;
|
|
||||||
|
|
||||||
/* scan along throwing away garbage characters until end of line
|
/* scan along throwing away garbage characters until end of line
|
||||||
or a separation char is found */
|
or a separation char is found */
|
||||||
|
|
@ -104,12 +103,9 @@ INPgetTok(char **line, char **token, int gobble)
|
||||||
if (point == *line && *point) /* Weird items, 1 char */
|
if (point == *line && *point) /* Weird items, 1 char */
|
||||||
point++;
|
point++;
|
||||||
|
|
||||||
diffpoints = (int)(point - *line);
|
*token = copy_substring(*line, point);
|
||||||
*token = TMALLOC(char, 1 + diffpoints);
|
|
||||||
if (!*token)
|
if (!*token)
|
||||||
return (E_NOMEM);
|
return (E_NOMEM);
|
||||||
(void) strncpy(*token, *line, (size_t) diffpoints);
|
|
||||||
*(*token + diffpoints) = '\0';
|
|
||||||
|
|
||||||
*line = point;
|
*line = point;
|
||||||
|
|
||||||
|
|
@ -150,7 +146,6 @@ INPgetNetTok(char **line, char **token, int gobble)
|
||||||
/* gobble: eat non-whitespace trash AFTER token? */
|
/* gobble: eat non-whitespace trash AFTER token? */
|
||||||
{
|
{
|
||||||
char *point;
|
char *point;
|
||||||
int diffpoints;
|
|
||||||
|
|
||||||
/* scan along throwing away garbage characters until end of line
|
/* scan along throwing away garbage characters until end of line
|
||||||
or a separation char is found */
|
or a separation char is found */
|
||||||
|
|
@ -194,12 +189,9 @@ INPgetNetTok(char **line, char **token, int gobble)
|
||||||
if (point == *line && *point) /* Weird items, 1 char */
|
if (point == *line && *point) /* Weird items, 1 char */
|
||||||
point++;
|
point++;
|
||||||
|
|
||||||
diffpoints = (int)(point - *line);
|
*token = copy_substring(*line, point);
|
||||||
*token = TMALLOC(char, 1 + diffpoints);
|
|
||||||
if (!*token)
|
if (!*token)
|
||||||
return (E_NOMEM);
|
return (E_NOMEM);
|
||||||
(void) strncpy(*token, *line, (size_t) diffpoints);
|
|
||||||
*(*token + diffpoints) = '\0';
|
|
||||||
|
|
||||||
*line = point;
|
*line = point;
|
||||||
|
|
||||||
|
|
@ -325,11 +317,9 @@ INPgetUTok(char **line, char **token, int gobble)
|
||||||
if (point == *line && *point) /* Weird items, 1 char */
|
if (point == *line && *point) /* Weird items, 1 char */
|
||||||
point++;
|
point++;
|
||||||
|
|
||||||
*token = TMALLOC(char, 1 + point - *line);
|
*token = copy_substring(*line, point);
|
||||||
if (!*token)
|
if (!*token)
|
||||||
return (E_NOMEM);
|
return (E_NOMEM);
|
||||||
(void) strncpy(*token, *line, (size_t) (point - *line));
|
|
||||||
*(*token + (point - *line)) = '\0';
|
|
||||||
|
|
||||||
/* gobble garbage to next token */
|
/* gobble garbage to next token */
|
||||||
for (; *point != '\0'; point++) {
|
for (; *point != '\0'; point++) {
|
||||||
|
|
@ -465,11 +455,9 @@ INPgetU2Tok(char **line, char **token, int gobble)
|
||||||
if (point == *line && *point) /* Weird items, 1 char */
|
if (point == *line && *point) /* Weird items, 1 char */
|
||||||
point++;
|
point++;
|
||||||
|
|
||||||
*token = TMALLOC(char, 1 + point - *line);
|
*token = copy_substring(*line, point);
|
||||||
if (!*token)
|
if (!*token)
|
||||||
return (E_NOMEM);
|
return (E_NOMEM);
|
||||||
(void) strncpy(*token, *line, (size_t) (point - *line));
|
|
||||||
*(*token + (point - *line)) = '\0';
|
|
||||||
|
|
||||||
/* gobble garbage to next token */
|
/* gobble garbage to next token */
|
||||||
for (; *point != '\0'; point++) {
|
for (; *point != '\0'; point++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue