"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/common/extract_vars.c" between
wcalc-2.4.1.tar.gz and wcalc-2.5.tar.gz

About: Wcalc is a natural-expression command-line calculator.

extract_vars.c  (wcalc-2.4.1):extract_vars.c  (wcalc-2.5)
skipping to change at line 18 skipping to change at line 18
#include <string.h> /* for strdup() */ #include <string.h> /* for strdup() */
/* Internal Headers */ /* Internal Headers */
#include "list.h" /* for List */ #include "list.h" /* for List */
#include "isfunc.h" #include "isfunc.h"
#include "isconst.h" #include "isconst.h"
#include "extract_vars.h" #include "extract_vars.h"
List extract_vars(char *str) List extract_vars(char *str)
{ /*{{{*/ { /*{{{*/
char *curs, *eov, save_char; char *curs, *eov;
List variables = NULL; List variables = NULL;
char *varname; char *varname;
curs = str; curs = str;
while (curs && *curs) { while (curs && *curs) {
// search for the first letter of a possible variable // search for the first letter of a possible variable
while (curs && *curs && !isalpha((int)(*curs))) { while (curs && *curs && !isalpha((int)(*curs))) {
if ((*curs == '\'') || (*curs == '#')) { if ((*curs == '\'') || (*curs == '#')) {
break; break;
} }
skipping to change at line 53 skipping to change at line 53
curs++; curs++;
} }
} }
// if we didn't find a first letter, we're done looking // if we didn't find a first letter, we're done looking
if ((*curs == 0) || (*curs == '#') || (*curs == '\'')) { if ((*curs == 0) || (*curs == '#') || (*curs == '\'')) {
break; break;
} }
// if we did find something, pull out the variable name // if we did find something, pull out the variable name
eov = curs; eov = curs;
while (eov && *eov && while (*eov &&
(isalpha((int)(*eov)) || *eov == '_' || *eov == ':' || (isalpha((int)(*eov)) || *eov == '_' || *eov == ':' ||
isdigit((int)(*eov)))) { isdigit((int)(*eov)))) {
eov++; eov++;
} }
save_char = *eov; {
*eov = 0; char save_char = *eov;
varname = (char *)strdup(curs); *eov = 0;
*eov = save_char; varname = (char *)strdup(curs);
curs = eov; *eov = save_char;
curs = eov;
}
// add it to the set of known variables // add it to the set of known variables
if (!isfunc(varname) && (isconst(varname) == W_notaconstant)) { if (!isfunc(varname) && !isconst(varname)) {
size_t i = 0; size_t i = 0;
char exists = 0; char exists = 0;
while (i < listLen(variables)) { while (i < listLen(variables)) {
char *peekstr = peekListElement(variables, i); char *peekstr = peekListElement(variables, i);
if (!strcmp(peekstr, varname)) { if (!strcmp(peekstr, varname)) {
exists = 1; exists = 1;
break; break;
} }
 End of changes. 4 change blocks. 
8 lines changed or deleted 10 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS