=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/util.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gnuplot/Attic/util.c 2000/01/09 17:00:56 1.1.1.1 +++ OpenXM_contrib/gnuplot/Attic/util.c 2000/01/22 14:16:02 1.1.1.2 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: util.c,v 1.1.1.1 2000/01/09 17:00:56 maekawa Exp $"; +static char *RCSid = "$Id: util.c,v 1.1.1.2 2000/01/22 14:16:02 maekawa Exp $"; #endif /* GNUPLOT - util.c */ @@ -103,8 +103,10 @@ char *str; register int start = token[t_num].start_index; register int length = token[t_num].length; + if (!str) + return FALSE; if (!token[t_num].is_token) - return (FALSE); /* must be a value--can't be equal */ + return FALSE; /* must be a value--can't be equal */ for (i = 0; i < length + after; i++) { if (str[i] != input_line[start + i]) { if (str[i] != '$') @@ -190,16 +192,18 @@ int max; { register int i = 0; register int start = token[t_num].start_index; - register int count; + register int count = token[t_num].length; - if ((count = token[t_num].length) >= max) { + if (count >= max) { count = max - 1; FPRINTF((stderr, "str buffer overflow in copy_str")); } + do { str[i++] = input_line[start++]; } while (i != count); str[i] = NUL; + } /* length of token string */ @@ -272,10 +276,8 @@ int start, end; register int i, e; register char *s; - if (*str) /* previous pointer to malloc'd memory there */ - free(*str); e = token[end].start_index + token[end].length; - *str = gp_alloc((unsigned long) (e - token[start].start_index + 1), "string"); + *str = gp_realloc(*str, (e - token[start].start_index + 1), "string"); s = *str; for (i = token[start].start_index; i < e && input_line[i] != NUL; i++) *s++ = input_line[i]; @@ -291,18 +293,19 @@ void m_quote_capture(str, start, end) char **str; int start, end; { - register int i, e, escflag = 0; + register int i, e; register char *s; - if (*str) /* previous pointer to malloc'd memory there */ - free(*str); e = token[end].start_index + token[end].length - 1; - *str = gp_alloc((unsigned long) (e - token[start].start_index + 1), "string"); + *str = gp_realloc(*str, (e - token[start].start_index + 1), "string"); s = *str; for (i = token[start].start_index + 1; i < e && input_line[i] != NUL; i++) - if ((*s++ = input_line[i]) == '\\') ++escflag; + *s++ = input_line[i]; *s = NUL; - if (escflag) parse_esc(*str); + + if (input_line[token[start].start_index] == '"') + parse_esc(*str); + }