inpcom.c, responding to bug report 275 by Dominique Michel: commands plot, hardcopy: no lower case letters in tokens following xlabel, ylabel, title
This commit is contained in:
parent
7198056a41
commit
2ece845f59
|
|
@ -870,28 +870,95 @@ inp_read(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile)
|
||||||
(void) strncpy(buffer + 1, "end of: ", 8);
|
(void) strncpy(buffer + 1, "end of: ", 8);
|
||||||
} /* end of .include handling */
|
} /* end of .include handling */
|
||||||
|
|
||||||
/* loop through 'buffer' until end is reached. Then test for
|
/* loop through 'buffer' until end is reached. Make all letters lower
|
||||||
premature end. If premature end is reached, spew
|
* case except for the commands given below. Special treatment for
|
||||||
error and zap the line. */
|
* commands 'hardcopy' and 'plot', where all letters are made lower
|
||||||
|
* case except for the tokens following xlabel, ylabel and title.
|
||||||
|
* These tokens may contain spaces, if they are enclosed in single or
|
||||||
|
* double quotes. Single quotes are later on swallowed and disappear,
|
||||||
|
* double quotes are printed. */
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
/* no lower case letters for lines beginning with: */
|
/* no lower case letters for lines beginning with: */
|
||||||
if ( !ciprefix("write", buffer) &&
|
if (!ciprefix("write", buffer) &&
|
||||||
!ciprefix("wrdata", buffer) &&
|
!ciprefix("wrdata", buffer) &&
|
||||||
!ciprefix(".lib", buffer) &&
|
!ciprefix(".lib", buffer) &&
|
||||||
!ciprefix(".inc", buffer) &&
|
!ciprefix(".inc", buffer) &&
|
||||||
!ciprefix("codemodel", buffer) &&
|
!ciprefix("codemodel", buffer) &&
|
||||||
!ciprefix("echo", buffer) &&
|
!ciprefix("echo", buffer) &&
|
||||||
!ciprefix("shell", buffer) &&
|
!ciprefix("shell", buffer) &&
|
||||||
!ciprefix("source", buffer) &&
|
!ciprefix("source", buffer) &&
|
||||||
!ciprefix("load", buffer)
|
!ciprefix("load", buffer) &&
|
||||||
|
!ciprefix("plot", buffer) &&
|
||||||
|
!ciprefix("hardcopy", buffer)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* lower case for all lines (exceptions see above!) */
|
/* lower case for all other lines */
|
||||||
for (s = buffer; *s && (*s != '\n'); s++)
|
for (s = buffer; *s && (*s != '\n'); s++)
|
||||||
*s = tolower_c(*s);
|
*s = tolower_c(*s);
|
||||||
|
} else if (ciprefix("plot", buffer) || ciprefix("hardcopy", buffer)) {
|
||||||
|
/* lower case excluded for tokens following title, xlabel, ylabel.
|
||||||
|
* tokens may contain spaces, then they have to be enclosed in quotes.
|
||||||
|
* keywords and tokens have to be separated by spaces. */
|
||||||
|
int j;
|
||||||
|
char t = ' ';
|
||||||
|
for (s = buffer; *s && (*s != '\n'); s++) {
|
||||||
|
*s = tolower_c(*s);
|
||||||
|
if (ciprefix("title", s)) {
|
||||||
|
/* jump beyond title */
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
s++;
|
||||||
|
*s = tolower_c(*s);
|
||||||
|
}
|
||||||
|
while (*s == ' ')
|
||||||
|
s++;
|
||||||
|
if (!s || (*s == '\n'))
|
||||||
|
break;
|
||||||
|
/* check if single quote is at start of token */
|
||||||
|
else if (*s == '\'') {
|
||||||
|
s++;
|
||||||
|
t = '\'';
|
||||||
|
}
|
||||||
|
/* check if double quote is at start of token */
|
||||||
|
else if (*s == '\"') {
|
||||||
|
s++;
|
||||||
|
t = '\"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
t = ' ';
|
||||||
|
/* jump beyond token without lower casing */
|
||||||
|
while ((*s != '\n') && (*s != t))
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
else if (ciprefix("xlabel", s) || ciprefix("ylabel", s)) {
|
||||||
|
/* jump beyond xlabel, ylabel */
|
||||||
|
for (j = 0; j < 6; j++) {
|
||||||
|
s++;
|
||||||
|
*s = tolower_c(*s);
|
||||||
|
}
|
||||||
|
while (*s == ' ')
|
||||||
|
s++;
|
||||||
|
if (!s || (*s == '\n'))
|
||||||
|
break;
|
||||||
|
/* check if single quote is at start of token */
|
||||||
|
else if (*s == '\'') {
|
||||||
|
s++;
|
||||||
|
t = '\'';
|
||||||
|
}
|
||||||
|
/* check if double quote is at start of token */
|
||||||
|
else if (*s == '\"') {
|
||||||
|
s++;
|
||||||
|
t = '\"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
t = ' ';
|
||||||
|
/* jump beyond token without lower casing */
|
||||||
|
while ((*s != '\n') && (*s != t))
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* exclude some commands to preserve filename case */
|
/* exclude commands listed above to preserve filename case */
|
||||||
for (s = buffer; *s && (*s != '\n'); s++)
|
for (s = buffer; *s && (*s != '\n'); s++)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue