comparison src/paranormal/libcalc/parser.c @ 1978:fa9f85cebade

s/vfs_/aud_vfs_/g
author William Pitcock <nenolod@atheme.org>
date Sun, 07 Oct 2007 00:25:33 -0500
parents 17311560f45f
children 6b427677621f
comparison
equal deleted inserted replaced
1977:5a6b60ceaa0f 1978:fa9f85cebade
1375 int yylex (YYSTYPE *yylval, void *yyparam) { 1375 int yylex (YYSTYPE *yylval, void *yyparam) {
1376 int c; 1376 int c;
1377 parser_control *pc = (parser_control *) yyparam; 1377 parser_control *pc = (parser_control *) yyparam;
1378 1378
1379 /* Ignore whitespace, get first nonwhite character. */ 1379 /* Ignore whitespace, get first nonwhite character. */
1380 while ((c = vfs_getc (pc->input)) == ' ' || c == '\t' || c == '\n'); 1380 while ((c = aud_vfs_getc (pc->input)) == ' ' || c == '\t' || c == '\n');
1381 1381
1382 /* End of input ? */ 1382 /* End of input ? */
1383 if (c == EOF) 1383 if (c == EOF)
1384 return 0; 1384 return 0;
1385 1385
1386 /* Char starts a number => parse the number. */ 1386 /* Char starts a number => parse the number. */
1387 if (isdigit (c)) { 1387 if (isdigit (c)) {
1388 vfs_fseek (pc->input, -1, SEEK_CUR); /* Put the char back. */ 1388 aud_vfs_fseek (pc->input, -1, SEEK_CUR); /* Put the char back. */
1389 { 1389 {
1390 char *old_locale, *saved_locale; 1390 char *old_locale, *saved_locale;
1391 1391
1392 old_locale = setlocale (LC_ALL, NULL); 1392 old_locale = setlocale (LC_ALL, NULL);
1393 saved_locale = g_strdup (old_locale); 1393 saved_locale = g_strdup (old_locale);
1394 setlocale (LC_ALL, "C"); 1394 setlocale (LC_ALL, "C");
1395 sscanf (((VFSBuffer *)(pc->input->handle))->iter, "%lf", &yylval->d_value); 1395 sscanf (((VFSBuffer *)(pc->input->handle))->iter, "%lf", &yylval->d_value);
1396 1396
1397 while (isdigit(c) || c == '.') 1397 while (isdigit(c) || c == '.')
1398 { 1398 {
1399 c = vfs_getc(pc->input); 1399 c = aud_vfs_getc(pc->input);
1400 } 1400 }
1401 1401
1402 vfs_fseek(pc->input, -1, SEEK_CUR); 1402 aud_vfs_fseek(pc->input, -1, SEEK_CUR);
1403 1403
1404 setlocale (LC_ALL, saved_locale); 1404 setlocale (LC_ALL, saved_locale);
1405 g_free (saved_locale); 1405 g_free (saved_locale);
1406 } 1406 }
1407 return NUMBER; 1407 return NUMBER;
1415 1415
1416 do { 1416 do {
1417 sym_name = g_string_append_c (sym_name, c); 1417 sym_name = g_string_append_c (sym_name, c);
1418 1418
1419 /* Get another character. */ 1419 /* Get another character. */
1420 c = vfs_getc (pc->input); 1420 c = aud_vfs_getc (pc->input);
1421 } while (c != EOF && isalnum (c)); 1421 } while (c != EOF && isalnum (c));
1422 1422
1423 vfs_fseek (pc->input, -1, SEEK_CUR); 1423 aud_vfs_fseek (pc->input, -1, SEEK_CUR);
1424 1424
1425 yylval->s_value = sym_name->str; 1425 yylval->s_value = sym_name->str;
1426 1426
1427 g_string_free (sym_name, FALSE); 1427 g_string_free (sym_name, FALSE);
1428 1428
1499 parser_control pc; 1499 parser_control pc;
1500 VFSFile *stream; 1500 VFSFile *stream;
1501 1501
1502 g_return_val_if_fail(str != NULL && dict != NULL, NULL); 1502 g_return_val_if_fail(str != NULL && dict != NULL, NULL);
1503 1503
1504 stream = vfs_buffer_new_from_string ( (char *) str ); 1504 stream = aud_vfs_buffer_new_from_string ( (char *) str );
1505 1505
1506 pc.input = stream; 1506 pc.input = stream;
1507 pc.expr = expr_new (); 1507 pc.expr = expr_new ();
1508 pc.dict = dict; 1508 pc.dict = dict;
1509 1509
1511 /* Check for error. */ 1511 /* Check for error. */
1512 expr_free (pc.expr); 1512 expr_free (pc.expr);
1513 pc.expr = NULL; 1513 pc.expr = NULL;
1514 } 1514 }
1515 1515
1516 vfs_fclose (stream); 1516 aud_vfs_fclose (stream);
1517 1517
1518 return pc.expr; 1518 return pc.expr;
1519 } 1519 }
1520 1520
1521 1521