You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(23) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(5) |
Feb
(22) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jose M. <ho...@us...> - 2005-06-25 23:49:59
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7283/src Modified Files: parser_stuff.c Log Message: - Fixed bug with variables ending in 'e' followed by '+' or '-' leche=2 leche+3 -> error tried to use the exponential notation (like 1e4) - Fixed bug with variables and specifying basis: a= 2 a_16 -> error, it understood 'a' as a variable Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** parser_stuff.c 24 Jun 2005 22:02:12 -0000 1.21 --- parser_stuff.c 25 Jun 2005 23:49:50 -0000 1.22 *************** *** 186,190 **** int yylex (void) { ! int epos, return_value, id; int handled=0; char *copy_text, aux; --- 186,190 ---- int yylex (void) { ! int epos, return_value, id, numdigits, i; int handled=0; char *copy_text, aux; *************** *** 201,211 **** epos= pos; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]==decimal_char) ++epos; // we've got an 'entry', lets check it if (epos>pos) { // check if we have an exponent coming up (only for base 10) ! if ((input[epos - 1]=='e' || input[epos - 1]=='E') && GetSystemVariable (SYSTEMVAR_IBASE)==10 && (input[epos]=='+' || input[epos]=='-')) { --- 201,216 ---- epos= pos; + numdigits= 0; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]==decimal_char) { ! if (isdigit ((int) input[epos])) ++numdigits; ! ++epos; ! } // we've got an 'entry', lets check it if (epos>pos) { // check if we have an exponent coming up (only for base 10) ! if (numdigits==epos - pos - 1 && ! (input[epos - 1]=='e' || input[epos - 1]=='E') && GetSystemVariable (SYSTEMVAR_IBASE)==10 && (input[epos]=='+' || input[epos]=='-')) { *************** *** 220,244 **** handled= 1; } else { // not syntactically open ! aux= input[epos]; ! input[epos]= '\0'; ! if ((id= CheckCommand (input + pos))!=-1) { // command ! yylval.id= id; ! return_value= COMMAND; ! } else if ((id= CheckFunction (input + pos))!=-1) { // it's a function ! yylval.id= id; ! return_value= FUNCTION; ! } else if (CheckVariable (input + pos)) { // it's a known variable ! copy_text= NewNameListEntry (input + pos); ! yylval.name= copy_text; ! return_value= VARIABLE; ! previous_token_closing_new= 1; ! } else { // it's an 'entry' (either new variable or number) copy_text= NewNameListEntry (input + pos); yylval.name= copy_text; return_value= ENTRY; previous_token_closing_new= 1; } - input[epos]= aux; - handled= 1; } } else { // no entry, just an operator (single character) --- 225,263 ---- handled= 1; } else { // not syntactically open ! // before trying to guess anything check we're not indicating a "based" number ! // if we don't do this we have problem with this: a=2 ; a_16 (it understands 'a' as a variable) ! for (i=epos; input[i]==' '; ++i); ! if (input[i]=='_') { // we are defining a based number, stop guessing ! aux= input[epos]; ! input[epos]= '\0'; copy_text= NewNameListEntry (input + pos); yylval.name= copy_text; return_value= ENTRY; previous_token_closing_new= 1; + input[epos]= aux; + handled= 1; + } else { // don't know yet, keep guessing + aux= input[epos]; + input[epos]= '\0'; + if ((id= CheckCommand (input + pos))!=-1) { // command + yylval.id= id; + return_value= COMMAND; + } else if ((id= CheckFunction (input + pos))!=-1) { // it's a function + yylval.id= id; + return_value= FUNCTION; + } else if (CheckVariable (input + pos)) { // it's a known variable + copy_text= NewNameListEntry (input + pos); + yylval.name= copy_text; + return_value= VARIABLE; + previous_token_closing_new= 1; + } else { // it's an 'entry' (either new variable or number) + copy_text= NewNameListEntry (input + pos); + yylval.name= copy_text; + return_value= ENTRY; + previous_token_closing_new= 1; + } + input[epos]= aux; + handled= 1; } } } else { // no entry, just an operator (single character) |
|
From: Jose M. <ho...@us...> - 2005-06-25 23:49:58
|
Update of /cvsroot/ganc/ganc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7283 Modified Files: README Log Message: - Fixed bug with variables ending in 'e' followed by '+' or '-' leche=2 leche+3 -> error tried to use the exponential notation (like 1e4) - Fixed bug with variables and specifying basis: a= 2 a_16 -> error, it understood 'a' as a variable Index: README =================================================================== RCS file: /cvsroot/ganc/ganc/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README 20 Nov 2003 03:31:37 -0000 1.1.1.1 --- README 25 Jun 2005 23:49:50 -0000 1.2 *************** *** 2,11 **** ================================================= ! ganc is just a simple algebraic calculator. ! Basically I didn't like any of the calculators available in my ! desktop. Like the very simple calculators where you start typing ! numbers and then after a few you make a mistake and everything you ! typed so far gets lost, so you have to start again from the ! beginning. What I needed was an algebraic calculator. But something simple, something easy to use. Something where you type '2+2' and you get 4, --- 2,9 ---- ================================================= ! ganc is a simple algebraic calculator. ! I didn't like any of the calculators available in my ! desktop. Don't like those simple calculators, I'm always making ! mistakes and getting the wrong result. What I needed was an algebraic calculator. But something simple, something easy to use. Something where you type '2+2' and you get 4, *************** *** 14,31 **** to go ahead and make my own. - To be completely truthfull, it wasn't until I had almost finished a - working version of ganc that I found 'rcalc'. - - - NOTES - ===== - - There's a lot of room for improvement in this project. - I'm sure it's going to have huuuuge portability issues. I'm only a - beginner in the amazing world of autoconf and automake. - I would like to make ganc more in sync with current gnome libraries, - i.e. getting rid of libzvt2 and start using vte. However, current - versions of vte won't work well with ganc. - BUILD --- 12,15 ---- *************** *** 36,40 **** - libgnomeui-2.x - gtk-2.x - - libzvt-2.x - readline - bison (or yacc) (note: not tested with yacc, but should work fine ;) ) --- 20,23 ---- |
|
From: Jose M. <ho...@us...> - 2005-06-24 22:02:23
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23731/src Modified Files: display.c main.c parser_stuff.c Log Message: main.c: Added fix so numbers always use locale "C", i.e. numbers use character '.' for decimal point regardless of current locale. In the future this should be a configurable option display.c: Eliminated a compile warning to do with a const variable Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** parser_stuff.c 22 Jun 2005 22:52:42 -0000 1.20 --- parser_stuff.c 24 Jun 2005 22:02:12 -0000 1.21 *************** *** 116,120 **** break; } ! printf ("decimal_char: %c\n", decimal_char); } --- 116,120 ---- break; } ! //printf ("decimal_char: %c\n", decimal_char); } Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** display.c 2 Dec 2004 20:29:54 -0000 1.7 --- display.c 24 Jun 2005 22:02:12 -0000 1.8 *************** *** 19,23 **** * ***********************************************************************/ ! static const char prompt[]="> "; static char *parse_errors[]={ // Texts of parse errors "unknown variable", // 1 --- 19,23 ---- * ***********************************************************************/ ! static char prompt[]="> "; static char *parse_errors[]={ // Texts of parse errors "unknown variable", // 1 Index: main.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/main.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** main.c 22 Jun 2005 22:52:42 -0000 1.14 --- main.c 24 Jun 2005 22:02:12 -0000 1.15 *************** *** 6,9 **** --- 6,10 ---- #include <string.h> #include <stdio.h> + #include <locale.h> #include <sys/wait.h> *************** *** 176,182 **** --- 177,193 ---- #ifdef BUILD_GUI + + // In theory we need this function to stop gtk_init from setting locale + // In practice it doesn't do anything + //gtk_disable_setlocale (); // Start gnome and gtk stuff gnome_init (PACKAGE, VERSION, argc, argv); + + // set LC_NUMERIC category to use C locale, i.e. '.' for deciman numbers + // according to gtk manual this is bad practice (set it after gtk_init) + // but it seems to be the only way to get it to work + setlocale (LC_NUMERIC, "C"); + SetUpInterface (); GetDecimalPoint (); |
|
From: Jose M. <ho...@us...> - 2005-06-22 22:53:04
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5536/src/include Modified Files: functions.h Log Message: Added stuff to detect and use the "decimal character" of the current locale Index: functions.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/functions.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** functions.h 2 Dec 2004 20:29:55 -0000 1.13 --- functions.h 22 Jun 2005 22:52:42 -0000 1.14 *************** *** 58,61 **** --- 58,62 ---- // parser_stuff.c + void GetDecimalPoint (void); int ParseTypedExpression (char *text); void PopErrorDialog (char *s); |
|
From: Jose M. <ho...@us...> - 2005-06-22 22:52:50
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5536/src Modified Files: main.c parser_stuff.c Log Message: Added stuff to detect and use the "decimal character" of the current locale Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** parser_stuff.c 8 Mar 2004 21:25:47 -0000 1.19 --- parser_stuff.c 22 Jun 2005 22:52:42 -0000 1.20 *************** *** 99,104 **** --- 99,121 ---- } parse_result; //int yydebug=1; // uncomment to get parser to print out status + static char decimal_char; + // Finds out decimal point used in current locale + // + // + void GetDecimalPoint (void) + { + char text[20]; + int i; + + sprintf (text, "%f", 0.1); + for (i=0; i<strlen (text); ++i) + if (!isdigit (text[i])) { + decimal_char= text[i]; + break; + } + printf ("decimal_char: %c\n", decimal_char); + } *************** *** 185,189 **** epos= pos; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]=='.') ++epos; // we've got an 'entry', lets check it --- 202,206 ---- epos= pos; while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]==decimal_char) ++epos; // we've got an 'entry', lets check it Index: main.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/main.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** main.c 2 Dec 2004 20:29:54 -0000 1.13 --- main.c 22 Jun 2005 22:52:42 -0000 1.14 *************** *** 68,71 **** --- 68,74 ---- // initialize system vars InitializeSystemVars (); + + // Find decimal character for current locale + GetDecimalPoint (); } *************** *** 177,180 **** --- 180,184 ---- gnome_init (PACKAGE, VERSION, argc, argv); SetUpInterface (); + GetDecimalPoint (); gtk_main (); // start gtk loop |
|
From: Jose M. <ho...@us...> - 2004-12-02 21:12:37
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1559/src Modified Files: callbacks.c display_gtk.c Log Message: Changed position where some local variables were declared. Solaris gcc compiler was complaining about them. Now it compiles in Solaris too. Index: callbacks.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/callbacks.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** callbacks.c 4 Mar 2004 00:41:54 -0000 1.13 --- callbacks.c 2 Dec 2004 21:12:27 -0000 1.14 *************** *** 190,193 **** --- 190,195 ---- gpointer user_data) { + GtkTextIter insert_iter, start_iter; + // // filter keys that don't behave nicely *************** *** 210,214 **** // handle normal keys // - GtkTextIter insert_iter, start_iter; // when key pressed produces text or is one of the list check that the --- 212,215 ---- Index: display_gtk.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_gtk.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** display_gtk.c 2 Dec 2004 20:29:54 -0000 1.2 --- display_gtk.c 2 Dec 2004 21:12:27 -0000 1.3 *************** *** 101,104 **** --- 101,108 ---- int width, height; // int ww, wh; + GtkRequisition toplevel_request; + GtkRequisition widget_request; + int w, h, xpad, ypad; + int grid_width, grid_height; // pcontext belongs to widget, so we don't free it *************** *** 121,129 **** // copied from gnome-terminal source (terminal-window.c) - GtkRequisition toplevel_request; - GtkRequisition widget_request; - int w, h, xpad, ypad; - int grid_width, grid_height; - gtk_widget_set_size_request (GTK_WIDGET (display), 2000, 2000); gtk_widget_size_request (GTK_WIDGET (window), &toplevel_request); --- 125,128 ---- |
|
From: Jose M. <ho...@us...> - 2004-12-02 20:30:07
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24745/src Modified Files: Makefile.am display.c display_gtk.c display_text.c main.c Log Message: First commit after a looooooooooong time, don't quite remember what has changed. Just syncing CVS with local copy Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** display.c 8 Mar 2004 21:25:47 -0000 1.6 --- display.c 2 Dec 2004 20:29:54 -0000 1.7 *************** *** 119,122 **** --- 119,143 ---- // + // + // + void TravelEntryHistory (int direction) + { + char *line, *line2=NULL; + + line= GetInputLine (); + if (line==NULL) return; // display modes that don't support history (text) + if (direction==HISTORY_PREVIOUS) { + line2= PreviousHistory (line); + } else if (direction==HISTORY_NEXT) { + line2= NextHistory (line); + } + free (line); + if (line2!=NULL) { + SetInputLine (line2); + } + } + + + // // Extracts position of sublines (indicated by ';' character) // Returns array with positions of ';' characters, i.e. ends of sublines *************** *** 186,190 **** // check line is not empty ! if (LineIsEmpty (line)) return; // add current line to history --- 207,214 ---- // check line is not empty ! if (LineIsEmpty (line)) { ! free (line); ! return; ! } // add current line to history Index: display_text.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_text.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** display_text.c 4 Mar 2004 00:41:54 -0000 1.4 --- display_text.c 2 Dec 2004 20:29:54 -0000 1.5 *************** *** 27,30 **** --- 27,33 ---- ***********************************************************************/ static int terminate=0; + static char *line; + static int line_ready; + *************** *** 34,39 **** --- 37,51 ---- void StartTextDisplay (void) { + line= (char *) malloc (MAX_LINE_SIZE + 1); + while (!terminate) { + line_ready= 0; PrintPrompt (); + + // read line + fgets (line, MAX_LINE_SIZE, stdin); + line[strlen (line) - 1]= '\0'; // eliminate end of line '\n' + + line_ready= 1; ExpressionReady (); } *************** *** 44,56 **** // // - void TravelEntryHistory (int direction) - { - /* nothing can be done for text displays */ - } - - - // - // - // void LimitNumberEntries (void) { --- 56,59 ---- *************** *** 61,76 **** // // Returns text in input line // char *GetInputLine (void) { ! char *line; ! ! line= (char *) malloc (MAX_LINE_SIZE + 1); ! fgets (line, MAX_LINE_SIZE, stdin); ! ! // eliminate end of line '\n' ! line[strlen (line) - 1]= '\0'; ! return line; } --- 64,76 ---- // // Returns text in input line + // returns NULL if line is not ready (text mode doesn't support history) // char *GetInputLine (void) { ! char *l=NULL; ! if (line_ready) l= strdup (line); ! ! return l; } Index: main.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/main.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** main.c 4 Mar 2004 00:41:54 -0000 1.12 --- main.c 2 Dec 2004 20:29:54 -0000 1.13 *************** *** 181,185 **** #else /* not BUILD_GUI */ ! StartTextDisplay (); #endif /* not BUILD_GUI */ --- 181,186 ---- #else /* not BUILD_GUI */ ! //StartTextDisplay (); ! StartCursesDisplay (); #endif /* not BUILD_GUI */ Index: Makefile.am =================================================================== RCS file: /cvsroot/ganc/ganc/src/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 4 Mar 2004 00:41:54 -0000 1.6 --- Makefile.am 2 Dec 2004 20:29:54 -0000 1.7 *************** *** 13,17 **** GUIHDR = callbacks.h interface.h support.h else ! GUISRC = display_text.c GUIHDR = endif --- 13,17 ---- GUIHDR = callbacks.h interface.h support.h else ! GUISRC = display_curses.c #display_text.c GUIHDR = endif *************** *** 21,25 **** variables.c display.c commands.c $(GUISRC) ! ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ EXTRA_DIST = include $(GUIHDR) --- 21,25 ---- variables.c display.c commands.c $(GUISRC) ! ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ -lncurses EXTRA_DIST = include $(GUIHDR) Index: display_gtk.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_gtk.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** display_gtk.c 4 Mar 2004 00:41:54 -0000 1.1 --- display_gtk.c 2 Dec 2004 20:29:54 -0000 1.2 *************** *** 167,190 **** // // - void TravelEntryHistory (int direction) - { - char *line, *line2=NULL; - - line= GetInputLine (); - if (direction==HISTORY_PREVIOUS) { - line2= PreviousHistory (line); - } else if (direction==HISTORY_NEXT) { - line2= NextHistory (line); - } - free (line); - if (line2!=NULL) { - SetInputLine (line2); - } - } - - - // - // - // void LimitNumberEntries (void) { --- 167,170 ---- |
|
From: Jose M. <ho...@us...> - 2004-12-02 20:30:06
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24745/src/include Modified Files: functions.h Log Message: First commit after a looooooooooong time, don't quite remember what has changed. Just syncing CVS with local copy Index: functions.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/functions.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** functions.h 4 Mar 2004 00:41:55 -0000 1.12 --- functions.h 2 Dec 2004 20:29:55 -0000 1.13 *************** *** 25,29 **** // display_gtk.c || display_text.c - void TravelEntryHistory (int direction); void LimitNumberEntries (void); char *GetInputLine (void); --- 25,28 ---- *************** *** 35,38 **** --- 34,38 ---- // display.c void PrintPrompt (void); + void TravelEntryHistory (int direction); void ExpressionReady (void); |
|
From: <ho...@us...> - 2004-03-08 21:42:27
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24651/src Modified Files: commands.c display.c parser_stuff.c Log Message: Fixed a bug that made ganc crash when trying to express 0 in a base different than 10 Index: commands.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/commands.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** commands.c 4 Mar 2004 00:41:54 -0000 1.1 --- commands.c 8 Mar 2004 21:25:47 -0000 1.2 *************** *** 9,13 **** #define COMMAND_EXIT 0 ! #define COMMAND_LS 1 --- 9,14 ---- #define COMMAND_EXIT 0 ! #define COMMAND_QUIT 1 ! #define COMMAND_LS 2 *************** *** 18,21 **** --- 19,25 ---- TerminateDisplay (); break; + case COMMAND_QUIT: + TerminateDisplay (); + break; case COMMAND_LS: break; Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** display.c 4 Mar 2004 00:41:54 -0000 1.5 --- display.c 8 Mar 2004 21:25:47 -0000 1.6 *************** *** 84,88 **** result= ResultValue (); // calculate number of digits number 'result' takes in base 'base' ! digits= (int) (log (result)/log (base) + 1); // malloc: 2 for '\n\0' and 2 for safety margin output_text= (char *) malloc (digits + 2 + 2 + extra_size); --- 84,89 ---- result= ResultValue (); // calculate number of digits number 'result' takes in base 'base' ! digits= (int) (log (labs (result))/log (base) + 1); ! if (digits < 1) digits= 1; // malloc: 2 for '\n\0' and 2 for safety margin output_text= (char *) malloc (digits + 2 + 2 + extra_size); Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** parser_stuff.c 4 Mar 2004 00:41:54 -0000 1.18 --- parser_stuff.c 8 Mar 2004 21:25:47 -0000 1.19 *************** *** 81,84 **** --- 81,85 ---- static char *command_names[]={ // Names of defined commands "exit", //0 + "quit", "ls", "" |
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3310/src Modified Files: Makefile.am callbacks.c display.c display_text.c main.c parser_stuff.c syntax.y variables.c Added Files: commands.c display_gtk.c Log Message: -Added support for commands in input line (only 'exit' so far) -Better defined gtk and simple text environments --- NEW FILE: commands.c --- #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "include/defines.h" #include "include/functions.h" #define COMMAND_EXIT 0 #define COMMAND_LS 1 void RunCommand (int com) { switch (com) { case COMMAND_EXIT: TerminateDisplay (); break; case COMMAND_LS: break; default: break; } } --- NEW FILE: display_gtk.c --- #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <gtk/gtk.h> #include <gconf/gconf-client.h> #include <pango/pango.h> #include "include/defines.h" #include "include/functions.h" #include "support.h" /*********************************************************************** * * External Variables * ***********************************************************************/ extern GtkTextBuffer *display_text_buffer; extern GtkWidget *display; /*********************************************************************** * * Global Variables * ***********************************************************************/ GtkTextMark *start_mark; GtkTextMark *end_mark; GtkTextMark *insert_mark; GtkTextMark *selection_mark; GtkTextMark *cursor_mark; /*********************************************************************** * * Local Constants * ***********************************************************************/ #define MAX_NUMBER_LINES 100 /*********************************************************************** * * Local Functions * ***********************************************************************/ // // Inserts text in display at cursor's position // checks insert point is not in forbidden zone // void InsertText (char *text) { GtkTextIter start_iter, sel_iter, insert_iter; gtk_text_buffer_get_selection_bounds (display_text_buffer, &sel_iter, &insert_iter); gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); if (gtk_text_iter_compare (&sel_iter, &start_iter)<0 || gtk_text_iter_compare (&insert_iter, &start_iter)<0) { gtk_text_buffer_get_iter_at_mark (display_text_buffer, &insert_iter, end_mark); gtk_text_buffer_place_cursor (display_text_buffer, &insert_iter); } gtk_text_buffer_insert_at_cursor (display_text_buffer, text, -1); } // // deletes the input line // void ClearInputLine (void) { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); gtk_text_buffer_get_iter_at_mark (display_text_buffer, &end_iter, end_mark); gtk_text_buffer_delete (display_text_buffer, &start_iter, &end_iter); gtk_text_buffer_place_cursor (display_text_buffer, &start_iter); } // // sets geometry hints for display (minimum size, size increment) // void SetDisplayGeometryHints (GtkWindow *window) { GdkGeometry hints; PangoLayout *playout; PangoContext *pcontext; int width, height; // int ww, wh; // pcontext belongs to widget, so we don't free it pcontext= gtk_widget_get_pango_context (GTK_WIDGET (display)); playout= pango_layout_new (pcontext); pango_layout_set_text(playout, "X", 1); pango_layout_get_pixel_size(playout, &width, &height); g_object_unref (G_OBJECT (playout)); // free created playout // geometry hints hints.base_width= 0; hints.base_height= 0; hints.width_inc= width; // x increment size hints.height_inc= height; // y increment size hints.min_width= 20*hints.width_inc; // min x size hints.min_height= 4*hints.height_inc; // min y size gtk_window_set_geometry_hints(window, GTK_WIDGET(display), &hints, GDK_HINT_RESIZE_INC|GDK_HINT_MIN_SIZE| GDK_HINT_BASE_SIZE);//|GDK_HINT_USER_SIZE); // copied from gnome-terminal source (terminal-window.c) GtkRequisition toplevel_request; GtkRequisition widget_request; int w, h, xpad, ypad; int grid_width, grid_height; gtk_widget_set_size_request (GTK_WIDGET (display), 2000, 2000); gtk_widget_size_request (GTK_WIDGET (window), &toplevel_request); gtk_widget_size_request (GTK_WIDGET (display), &widget_request); w= toplevel_request.width - widget_request.width; h= toplevel_request.height - widget_request.height; grid_width= 30; grid_height= 10; xpad= 0; ypad= 0; w+= xpad + width * grid_width; h+= ypad + height * grid_height; //gtk_window_resize (window, w, h); gtk_window_set_default_size (window, w, h); } // // get monospace font (terminal font) from gnome preferences (gconf) // set font for display // void SetDisplayDefaultFont (void) { PangoFontDescription *monospace_font_desc; GConfClient *conf_client; conf_client= gconf_client_get_default (); monospace_font_desc= pango_font_description_from_string (gconf_client_get_string (conf_client, "/desktop/gnome/interface/monospace_font_name", NULL)); gtk_widget_modify_font (display, monospace_font_desc); pango_font_description_free (monospace_font_desc); g_object_unref (G_OBJECT (conf_client)); // free conf_client } // // // void TravelEntryHistory (int direction) { char *line, *line2=NULL; line= GetInputLine (); if (direction==HISTORY_PREVIOUS) { line2= PreviousHistory (line); } else if (direction==HISTORY_NEXT) { line2= NextHistory (line); } free (line); if (line2!=NULL) { SetInputLine (line2); } } // // // void LimitNumberEntries (void) { int lines; GtkTextIter iter, start_iter; GtkTextTag *result_tag; lines= gtk_text_buffer_get_line_count (display_text_buffer); if (lines>MAX_NUMBER_LINES) { gtk_text_buffer_get_iter_at_offset (display_text_buffer, &start_iter, 0); gtk_text_buffer_get_iter_at_offset (display_text_buffer, &iter, 0); result_tag= gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table (display_text_buffer), "result"); gtk_text_iter_forward_to_tag_toggle (&iter, result_tag); // start result gtk_text_iter_forward_to_tag_toggle (&iter, result_tag); // end result gtk_text_buffer_delete (display_text_buffer, &start_iter, &iter); } } // // Returns text in input line // char *GetInputLine (void) { char *line; GtkTextIter start_iter, end_iter; gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); gtk_text_buffer_get_iter_at_mark (display_text_buffer, &end_iter, end_mark); line= gtk_text_buffer_get_text (display_text_buffer, &start_iter, &end_iter, FALSE); return line; } // // Sets input line to text in 'line' // void SetInputLine (char *line) { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); gtk_text_buffer_get_iter_at_mark (display_text_buffer, &end_iter, end_mark); gtk_text_buffer_delete (display_text_buffer, &start_iter, &end_iter); gtk_text_buffer_insert (display_text_buffer, &start_iter, line, -1); gtk_text_buffer_place_cursor (display_text_buffer, &start_iter); } // // Appends 'text' at the end of everything in display, using format // properties in 'prop' // void AppendDisplayText (char *text, int prop) { GtkTextIter point_iter; gtk_text_buffer_get_iter_at_mark (display_text_buffer, &point_iter, end_mark); if (prop==DISPLAY_TAG_PLAIN) { gtk_text_buffer_insert (display_text_buffer, &point_iter, text, -1); } else if (prop==DISPLAY_TAG_RESULT) { gtk_text_buffer_insert (display_text_buffer, &point_iter, "\n", -1); gtk_text_buffer_insert_with_tags_by_name (display_text_buffer, &point_iter, text, -1, "result", NULL); } else if (prop==DISPLAY_TAG_ERROR) { gtk_text_buffer_insert (display_text_buffer, &point_iter, "\n", -1); gtk_text_buffer_insert_with_tags_by_name (display_text_buffer, &point_iter, text, -1, "error", NULL); } } // // update all the needed stuff after output is finished and a new input line // should be ready to be entered // void UpdateDisplayAfterOutput (void) { GtkTextIter point_iter; PrintPrompt (); // get pos at end of buffer gtk_text_buffer_get_iter_at_mark (display_text_buffer, &point_iter, end_mark); // set 'start' and 'end' marks and position cursor gtk_text_buffer_move_mark (display_text_buffer, start_mark, &point_iter); gtk_text_buffer_move_mark (display_text_buffer, end_mark, &point_iter); gtk_text_buffer_place_cursor (display_text_buffer, &point_iter); // scroll display to show cursor (if necessary) gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (display), insert_mark, 0., FALSE, 0., 0.); } // // Handles a terminate request (typed 'exit' in input) // void TerminateDisplay (void) { gtk_main_quit (); } /* Local Variables: c-file-style: "gnu" c-file-offsets: ((case-label . +)) End: */ Index: Makefile.am =================================================================== RCS file: /cvsroot/ganc/ganc/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 27 Feb 2004 00:34:07 -0000 1.5 --- Makefile.am 4 Mar 2004 00:41:54 -0000 1.6 *************** *** 10,14 **** ## GUI extra sources and headers if BUILD_GUI ! GUISRC = support.c interface.c callbacks.c display.c GUIHDR = callbacks.h interface.h support.h else --- 10,14 ---- ## GUI extra sources and headers if BUILD_GUI ! GUISRC = support.c interface.c callbacks.c display_gtk.c GUIHDR = callbacks.h interface.h support.h else *************** *** 19,23 **** ganc_SOURCES = main.c evaluate.c syntax.y parser_stuff.c history.c \ ! variables.c $(GUISRC) ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ --- 19,23 ---- ganc_SOURCES = main.c evaluate.c syntax.y parser_stuff.c history.c \ ! variables.c display.c commands.c $(GUISRC) ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ Index: callbacks.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/callbacks.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** callbacks.c 4 Feb 2004 00:32:10 -0000 1.12 --- callbacks.c 4 Mar 2004 00:41:54 -0000 1.13 *************** *** 250,257 **** if (event->keyval==GDK_Up || event->keyval==GDK_Down || event->keyval==GDK_Page_Up || event->keyval==GDK_Page_Down) { ! TravelEntryHistory (event->keyval); gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key-press-event"); return TRUE; } // HOME pressed if (event->keyval==GDK_Home) { --- 250,262 ---- if (event->keyval==GDK_Up || event->keyval==GDK_Down || event->keyval==GDK_Page_Up || event->keyval==GDK_Page_Down) { ! if (event->keyval==GDK_Up || event->keyval==GDK_Page_Up) { ! TravelEntryHistory (HISTORY_PREVIOUS); ! } else if (event->keyval==GDK_Down || event->keyval==GDK_Page_Down) { ! TravelEntryHistory (HISTORY_NEXT); ! } gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key-press-event"); return TRUE; } + // HOME pressed if (event->keyval==GDK_Home) { Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** display.c 27 Feb 2004 03:04:52 -0000 1.4 --- display.c 4 Mar 2004 00:41:54 -0000 1.5 *************** *** 8,50 **** #include <math.h> #include <string.h> - #include <gtk/gtk.h> - #include <gdk/gdkkeysyms.h> - #include <gconf/gconf-client.h> - #include <pango/pango.h> #include "include/defines.h" #include "include/functions.h" - #include "support.h" - /*********************************************************************** - * - * External Variables - * - ***********************************************************************/ - extern GtkTextBuffer *display_text_buffer; - extern GtkWidget *display; - - - /*********************************************************************** - * - * Global Variables - * - ***********************************************************************/ - GtkTextMark *start_mark; - GtkTextMark *end_mark; - GtkTextMark *insert_mark; - GtkTextMark *selection_mark; - GtkTextMark *cursor_mark; - - - - /*********************************************************************** - * - * Local Constants - * - ***********************************************************************/ - #define MAX_NUMBER_LINES 100 - /*********************************************************************** --- 8,16 ---- *************** *** 82,86 **** * ***********************************************************************/ - static void LimitNumberEntries (void); static char *PreparePrintedResult (void); static int *ExtractSublines (char *line, int *num_sublines); --- 48,51 ---- *************** *** 93,183 **** // prints prompt in display // ! void PrintPrompt (GtkTextIter *point_iter) ! { ! gtk_text_buffer_insert (display_text_buffer, point_iter, prompt, -1); ! } ! ! ! // ! // ! // ! void TravelEntryHistory (guint keyval) ! { ! char *line, *line2=NULL; ! GtkTextIter start_iter, end_iter; ! ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &end_iter, end_mark); ! line= gtk_text_buffer_get_text (display_text_buffer, &start_iter, &end_iter, FALSE); ! if (keyval==GDK_Up) { ! line2= PreviousHistory (line); ! } else if (keyval==GDK_Down) { ! line2= NextHistory (line); ! } else if (keyval==GDK_Page_Up) { ! line2= PreviousHistory (line); ! } else if (keyval==GDK_Page_Down) { ! line2= NextHistory (line); ! } ! free (line); ! if (line2!=NULL) { ! gtk_text_buffer_delete (display_text_buffer, &start_iter, &end_iter); ! gtk_text_buffer_insert (display_text_buffer, &start_iter, line2, -1); ! gtk_text_buffer_place_cursor (display_text_buffer, &start_iter); ! } ! } ! ! ! // ! // Inserts text in display at cursor's position ! // checks insert point is not in forbidden zone ! // ! void InsertText (char *text) ! { ! GtkTextIter start_iter, sel_iter, insert_iter; ! ! gtk_text_buffer_get_selection_bounds (display_text_buffer, &sel_iter, &insert_iter); ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); ! if (gtk_text_iter_compare (&sel_iter, &start_iter)<0 || ! gtk_text_iter_compare (&insert_iter, &start_iter)<0) { ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &insert_iter, end_mark); ! gtk_text_buffer_place_cursor (display_text_buffer, &insert_iter); ! } ! gtk_text_buffer_insert_at_cursor (display_text_buffer, text, -1); ! } ! ! ! // ! // deletes the input line ! // ! void ClearInputLine (void) ! { ! GtkTextIter start_iter, end_iter; ! ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &end_iter, end_mark); ! gtk_text_buffer_delete (display_text_buffer, &start_iter, &end_iter); ! gtk_text_buffer_place_cursor (display_text_buffer, &start_iter); ! } ! ! ! // ! // ! // ! static void LimitNumberEntries (void) { ! int lines; ! GtkTextIter iter, start_iter; ! GtkTextTag *result_tag; ! ! lines= gtk_text_buffer_get_line_count (display_text_buffer); ! ! if (lines>MAX_NUMBER_LINES) { ! gtk_text_buffer_get_iter_at_offset (display_text_buffer, &start_iter, 0); ! gtk_text_buffer_get_iter_at_offset (display_text_buffer, &iter, 0); ! result_tag= gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table (display_text_buffer), "result"); ! gtk_text_iter_forward_to_tag_toggle (&iter, result_tag); // start result ! gtk_text_iter_forward_to_tag_toggle (&iter, result_tag); // end result ! gtk_text_buffer_delete (display_text_buffer, &start_iter, &iter); ! } } --- 58,64 ---- // prints prompt in display // ! void PrintPrompt (void) { ! AppendDisplayText (prompt, DISPLAY_TAG_PLAIN); } *************** *** 294,299 **** void ExpressionReady (void) { ! GtkTextIter point_iter, start_iter; ! gchar *line, *extra; int error; int num_sublines, start, i; --- 175,179 ---- void ExpressionReady (void) { ! char *line, *extra; int error; int num_sublines, start, i; *************** *** 302,308 **** int perror, size; ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &start_iter, start_mark); ! gtk_text_buffer_get_iter_at_mark (display_text_buffer, &point_iter, end_mark); ! line= gtk_text_buffer_get_text (display_text_buffer, &start_iter, &point_iter, FALSE); // check line is not empty --- 182,186 ---- int perror, size; ! line= GetInputLine (); // check line is not empty *************** *** 311,316 **** // add current line to history AddHistory (line); - - gtk_text_buffer_insert (display_text_buffer, &point_iter, "\n", -1); // extract sub-lines from input --- 189,192 ---- *************** *** 346,360 **** free (extra); } ! gtk_text_buffer_insert_with_tags_by_name ! (display_text_buffer, &point_iter, output_text, -1, "result", "error", NULL); } else { // No error, print result output_text= PreparePrintedResult (); ! gtk_text_buffer_insert_with_tags_by_name ! (display_text_buffer, &point_iter, output_text, -1, "result", NULL); } - // print output_text (it should already end in '\n') using tag 'result' - - // free memory of output text free (output_text); --- 222,231 ---- free (extra); } ! AppendDisplayText (output_text, DISPLAY_TAG_ERROR); } else { // No error, print result output_text= PreparePrintedResult (); ! AppendDisplayText (output_text, DISPLAY_TAG_RESULT); } // free memory of output text free (output_text); *************** *** 365,380 **** // free memory free (sublines); ! g_free (line); ! PrintPrompt (&point_iter); ! ! // set 'start' and 'end' marks and position cursor ! gtk_text_buffer_move_mark (display_text_buffer, start_mark, &point_iter); ! gtk_text_buffer_move_mark (display_text_buffer, end_mark, &point_iter); ! gtk_text_buffer_place_cursor (display_text_buffer, &point_iter); ! ! // scroll display to show cursor (if necessary) ! gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (display), insert_mark, ! 0., FALSE, 0., 0.); // make sure number of entries in display doesn't exceed a maximum --- 236,243 ---- // free memory free (sublines); ! free (line); ! // get ready for next input line ! UpdateDisplayAfterOutput (); // make sure number of entries in display doesn't exceed a maximum *************** *** 383,458 **** - // - // sets geometry hints for display (minimum size, size increment) - // - void SetDisplayGeometryHints (GtkWindow *window) - { - GdkGeometry hints; - PangoLayout *playout; - PangoContext *pcontext; - int width, height; - int ww, wh; - - // pcontext belongs to widget, so we don't free it - pcontext= gtk_widget_get_pango_context (GTK_WIDGET (display)); - playout= pango_layout_new (pcontext); - pango_layout_set_text(playout, "X", 1); - pango_layout_get_pixel_size(playout, &width, &height); - g_object_unref (G_OBJECT (playout)); // free created playout - - // geometry hints - hints.base_width= 0; - hints.base_height= 0; - hints.width_inc= width; // x increment size - hints.height_inc= height; // y increment size - hints.min_width= 20*hints.width_inc; // min x size - hints.min_height= 4*hints.height_inc; // min y size - gtk_window_set_geometry_hints(window, GTK_WIDGET(display), &hints, - GDK_HINT_RESIZE_INC|GDK_HINT_MIN_SIZE| - GDK_HINT_BASE_SIZE);//|GDK_HINT_USER_SIZE); - - // copied from gnome-terminal source (terminal-window.c) - GtkRequisition toplevel_request; - GtkRequisition widget_request; - int w, h, xpad, ypad; - int grid_width, grid_height; - - gtk_widget_set_size_request (GTK_WIDGET (display), 2000, 2000); - gtk_widget_size_request (window, &toplevel_request); - gtk_widget_size_request (GTK_WIDGET (display), &widget_request); - - w= toplevel_request.width - widget_request.width; - h= toplevel_request.height - widget_request.height; - - grid_width= 30; - grid_height= 10; - - xpad= 0; - ypad= 0; - - w+= xpad + width * grid_width; - h+= ypad + height * grid_height; - - //gtk_window_resize (window, w, h); - gtk_window_set_default_size (window, w, h); - } - - - // - // get monospace font (terminal font) from gnome preferences (gconf) - // set font for display - // - void SetDisplayDefaultFont (void) - { - PangoFontDescription *monospace_font_desc; - GConfClient *conf_client; - - conf_client= gconf_client_get_default (); - monospace_font_desc= pango_font_description_from_string (gconf_client_get_string (conf_client, "/desktop/gnome/interface/monospace_font_name", NULL)); - gtk_widget_modify_font (display, monospace_font_desc); - pango_font_description_free (monospace_font_desc); - g_object_unref (G_OBJECT (conf_client)); // free conf_client - } - /* --- 246,249 ---- Index: display_text.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_text.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** display_text.c 27 Feb 2004 03:04:52 -0000 1.3 --- display_text.c 4 Mar 2004 00:41:54 -0000 1.4 *************** *** 15,237 **** /*********************************************************************** * ! * Local Variables * ***********************************************************************/ ! static const char prompt[]="> "; ! static char *parse_errors[]={ // Texts of parse errors ! "unknown variable", // 1 ! "syntax error", ! "parse error", ! "isolated decimal dot", ! "", // 5 ! "base out of range", ! "base conversion error", ! "invalid argument to LN", ! "invalid argument to LOG", ! "invalid argument to factorial", // 10 ! "invalid argument to SQRT", ! "invalid argument to ASIN", ! "invalid argument to ACOS", ! "division by zero", ! "overflow", // 15 ! "NaN", ! "assignment of constant", ! "illegal identifier", ! "illegal constant" ! }; /*********************************************************************** * ! * Local Functions * ***********************************************************************/ ! static char *PreparePrintedResult (void); ! static int *ExtractSublines (char *line, int *num_sublines); ! static int LineIsEmpty (char *line); ! // ! // prepare text that will be outputed as output // ! static char *PreparePrintedResult (void) { ! unsigned long result; ! int digits, i, d, aux; ! unsigned int base; ! char *output_text; ! int printbase, extra_size=0; ! ! base= GetResultOutputFormat (OUTPUT_FORMAT_BASE); ! printbase= GetResultOutputFormat (OUTPUT_FORMAT_PRINTBASE); ! if (printbase) extra_size= 3; ! if (base==10) { // base 10 -> EASY ! output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, FORMAT_STRING, ResultValue ()); ! i= 0; ! while (output_text[i]==' ') ++i; ! strcpy (output_text, output_text + i); ! } else { // other base ! result= ResultValue (); ! // calculate number of digits number 'result' takes in base 'base' ! digits= (int) (log (result)/log (base) + 1); ! // malloc: 2 for '\n\0' and 2 for safety margin ! output_text= (char *) malloc (digits + 2 + 2 + extra_size); ! i= 0; ! while (result >= base) { ! d= result % base; ! if (d<10) output_text[i++]= d + '0'; ! else output_text[i++]= (d - 10) + 'a'; ! result/= base; ! } ! if (result<10) output_text[i]= result + '0'; ! else output_text[i]= (result - 10) + 'a'; ! output_text[i + 1]= '\n'; ! output_text[i + 2]= '\0'; ! d= 0; ! while (d<i) { ! aux= output_text[i]; ! output_text[i]= output_text[d]; ! output_text[d]= aux; ! --i; ! d++; ! } ! } ! if (printbase) { ! i= strlen (output_text) - 1; ! if (base<10) sprintf (output_text + i, "_%1d\n", base); ! else sprintf (output_text + i, "_%2d\n", base); } ! ! return output_text; ! } // - // Extracts position of sublines (indicated by ';' character) - // Returns array with positions of ';' characters, i.e. ends of sublines - // and number of sublines found (minimum 1) in 'num_sublines' - // array contains at least one element, i.e. end of line - // Returned array needs to be freed later // ! static int *ExtractSublines (char *line, int *num_sublines) { ! int *sublines; ! int count, i, j, size; ! ! // store size of line ! size= strlen (line); ! ! // find sub-lines embeded in input ! // run through the input to find ';' characters, store positions in 'sublines' ! for (i= 0, count= 0; i<size; ++i) if (line[i]==';') ++count; ! ++count; // at least 1: case of no sub-lines ! sublines= malloc (count*sizeof (int)); - // If some sub-lines are found, store their positions - if (count>1) { // there were some ';' - for (i= 0, j= 0; i<size; ++i) - if (line[i]==';') { - sublines[j]= i; - ++j; - } - } - // consider end of input as the end of another sub-line - // it makes the case with no sub-lines work - sublines[count - 1]= size; ! *num_sublines= count; ! return sublines; } // ! // returns 1 if line is empty (0 or more spaces); returns 0 otherwise // ! static int LineIsEmpty (char *line) { ! int i; ! i= strlen (line) - 1; ! while (i>=0 && line[i]==' ') --i; ! if (i>=0) return 0; ! return 1; } ! #define MAX_LINE_SIZE 200 ! ! void TextDisplay (void) ! { ! char line[MAX_LINE_SIZE + 1], *extra; ! int error; ! int num_sublines, start, i; ! int *sublines = NULL; ! char *output_text; ! int perror, size; ! ! while (1) { ! // read line ! printf ("%s", prompt); ! fgets (line, MAX_LINE_SIZE, stdin); - line[strlen (line) - 1]= '\0'; - // 'exit' entered? - if (strcmp (line, "exit")==0) break; - - // check line is not empty - if (LineIsEmpty (line)) continue; - - // extract sub-lines from input - sublines= ExtractSublines (line, &num_sublines); - start= 0; // stores starting position of sub-line - for (i= 0; i<num_sublines; ++i) { - line[sublines[i]]= '\0'; - // ignore empty sublines - if (LineIsEmpty (line + start)) { - start= sublines[i] + 1; - continue; - } - error= ParseTypedExpression (line + start); ! if (error) { ! // see if there's any extra text to add to error output ! perror= ParseError (); ! extra= ParseErrorExtra (); ! ! if (extra==NULL) { ! size= 20; ! size+= strlen (parse_errors[perror - 1]); ! output_text= (char *) malloc (size); ! //sprintf (output_text, "error: %s\n", parse_errors[perror - 1]); ! sprintf (output_text, "%s\n", parse_errors[perror - 1]); ! } else { ! size= 30; ! size+= strlen (parse_errors[perror - 1]); ! size+= strlen (extra); ! output_text= (char *) malloc (size); ! //sprintf (output_text, "error: %s: %s\n", parse_errors[perror - 1], extra); ! sprintf (output_text, "%s: %s\n", parse_errors[perror - 1], extra); ! free (extra); ! } ! } else { // No error, print result ! output_text= PreparePrintedResult (); ! } - // print output_text (it should already end in '\n') using tag 'result' - printf ("%s", output_text); ! // free memory of output text ! free (output_text); ! ! // set start of next subline ! start= sublines[i] + 1; ! } ! // free memory ! free (sublines); ! } } --- 15,113 ---- /*********************************************************************** * ! * Local Constants * ***********************************************************************/ ! #define MAX_LINE_SIZE 200 /*********************************************************************** * ! * Local Variables * ***********************************************************************/ ! static int terminate=0; // ! // main function for text display // ! void StartTextDisplay (void) { ! while (!terminate) { ! PrintPrompt (); ! ExpressionReady (); } ! } // // ! // ! void TravelEntryHistory (int direction) { ! /* nothing can be done for text displays */ ! } ! // ! // ! // ! void LimitNumberEntries (void) ! { ! /* nothing can be done for text displays */ } // ! // Returns text in input line // ! char *GetInputLine (void) { ! char *line; ! line= (char *) malloc (MAX_LINE_SIZE + 1); ! fgets (line, MAX_LINE_SIZE, stdin); ! // eliminate end of line '\n' ! line[strlen (line) - 1]= '\0'; ! ! return line; } + // + // Sets input line to text in 'line' + // + void SetInputLine (char *line) + { + /* nothing can be done in text displays */ + } ! // ! // Appends 'text' at the end of everything in display, using format ! // properties in 'prop' ! // ! void AppendDisplayText (char *text, int prop) ! { ! if (!terminate) printf ("%s", text); ! } ! // ! // update all the needed stuff after output is finished and a new input line ! // should be ready to be entered ! // ! void UpdateDisplayAfterOutput (void) ! { ! /* nothing is required for text displays */ ! } ! // ! // Handles a terminate request (typed 'exit' in input) ! // ! void TerminateDisplay (void) ! { ! terminate= 1; } Index: main.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/main.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** main.c 27 Feb 2004 00:34:07 -0000 1.11 --- main.c 4 Mar 2004 00:41:54 -0000 1.12 *************** *** 38,41 **** --- 38,43 ---- extern GtkTextMark *cursor_mark; + static void SetUpInterface (void); + #endif /* BUILD_GUI */ *************** *** 46,50 **** ***********************************************************************/ static void InitializeVars (void); - static void SetUpInterface (void); static void CleanUp (void); --- 48,51 ---- *************** *** 120,123 **** --- 121,126 ---- // create tags gtk_text_buffer_create_tag (display_text_buffer, "error", + "justification", GTK_JUSTIFY_RIGHT, + "right-margin", 10, "foreground", "red", NULL); *************** *** 127,133 **** NULL); ! // create initial mark for start of line gtk_text_buffer_get_iter_at_offset (display_text_buffer, &start_iter, 0); ! PrintPrompt (&start_iter); start_mark= gtk_text_buffer_create_mark (display_text_buffer, "start-line", &start_iter, TRUE); --- 130,136 ---- NULL); ! // create marks gtk_text_buffer_get_iter_at_offset (display_text_buffer, &start_iter, 0); ! start_mark= gtk_text_buffer_create_mark (display_text_buffer, "start-line", &start_iter, TRUE); *************** *** 139,142 **** --- 142,147 ---- selection_mark= gtk_text_buffer_get_mark (display_text_buffer, "selection_bound"); + // print prompt and get display ready for input line + UpdateDisplayAfterOutput (); // signal connections *************** *** 176,180 **** #else /* not BUILD_GUI */ ! TextDisplay (); #endif /* not BUILD_GUI */ --- 181,185 ---- #else /* not BUILD_GUI */ ! StartTextDisplay (); #endif /* not BUILD_GUI */ Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** parser_stuff.c 27 Feb 2004 02:44:28 -0000 1.17 --- parser_stuff.c 4 Mar 2004 00:41:54 -0000 1.18 *************** *** 79,82 **** --- 79,87 ---- "" }; + static char *command_names[]={ // Names of defined commands + "exit", //0 + "ls", + "" + }; static int previous_token_closing; // set when last token was a 'syntactically closing' token static int initial_pos; *************** *** 143,146 **** --- 148,167 ---- // + // Checks 'entry' to see if it's a known command + // Returns: ID of command if found, -1 if command not found + // + static int CheckCommand (char *entry) + { + int i=0; + int found=0; + + while (*command_names[i]!='\x0' && !found) + found= !strcmp (entry, command_names[i++]); + if (found) --i; else i= -1; + return i; + } + + + // // Lexical function called by parser // returns the token *************** *** 183,187 **** aux= input[epos]; input[epos]= '\0'; ! if ((id= CheckFunction (input + pos))!=-1) { // it's a function yylval.id= id; return_value= FUNCTION; --- 204,211 ---- aux= input[epos]; input[epos]= '\0'; ! if ((id= CheckCommand (input + pos))!=-1) { // command ! yylval.id= id; ! return_value= COMMAND; ! } else if ((id= CheckFunction (input + pos))!=-1) { // it's a function yylval.id= id; return_value= FUNCTION; Index: syntax.y =================================================================== RCS file: /cvsroot/ganc/ganc/src/syntax.y,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** syntax.y 4 Feb 2004 02:54:32 -0000 1.8 --- syntax.y 4 Mar 2004 00:41:54 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- %token <name> ENTRY %token <id> FUNCTION + %token <id> COMMAND %token <name> VARIABLE %token <id> LEX_ERROR *************** *** 41,44 **** --- 42,46 ---- | exp ':' ':' format_string { OutputResult ($1); if (CheckForErrors ()) YYABORT; } + | COMMAND { RunCommand ($1); } ; Index: variables.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/variables.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** variables.c 27 Feb 2004 02:44:28 -0000 1.3 --- variables.c 4 Mar 2004 00:41:54 -0000 1.4 *************** *** 339,342 **** --- 339,351 ---- + // + // Prints variable list to display + // + void PrintVarList (int filter) + { + + } + + /* Local Variables: |
|
From: <ho...@us...> - 2004-03-04 00:54:51
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3310/src/include Modified Files: defines.h functions.h parser.h Log Message: -Added support for commands in input line (only 'exit' so far) -Better defined gtk and simple text environments Index: defines.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/defines.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** defines.h 27 Feb 2004 03:04:52 -0000 1.4 --- defines.h 4 Mar 2004 00:41:55 -0000 1.5 *************** *** 151,154 **** --- 151,165 ---- + // tags for output text in display + #define DISPLAY_TAG_PLAIN 0 + #define DISPLAY_TAG_RESULT 1 + #define DISPLAY_TAG_ERROR 2 + + + // directions for history travel + #define HISTORY_PREVIOUS 0 + #define HISTORY_NEXT 1 + + #endif /* end of defines.h */ Index: functions.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/functions.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** functions.h 27 Feb 2004 00:34:07 -0000 1.11 --- functions.h 4 Mar 2004 00:41:55 -0000 1.12 *************** *** 11,20 **** #include <gtk/gtk.h> ! // display.c ! void PrintPrompt (GtkTextIter *point_iter); ! void TravelEntryHistory (guint keyval); void InsertText (char *text); void ClearInputLine (void); - void ExpressionReady (void); void SetDisplayGeometryHints (GtkWindow *window); void SetDisplayDefaultFont (void); --- 11,17 ---- #include <gtk/gtk.h> ! // display_gtk.c void InsertText (char *text); void ClearInputLine (void); void SetDisplayGeometryHints (GtkWindow *window); void SetDisplayDefaultFont (void); *************** *** 23,30 **** // display_text.c ! void TextDisplay (void); #endif /* not BUILD_GUI */ // evaluate.c --- 20,39 ---- // display_text.c ! void StartTextDisplay (void); #endif /* not BUILD_GUI */ + // display_gtk.c || display_text.c + void TravelEntryHistory (int direction); + void LimitNumberEntries (void); + char *GetInputLine (void); + void SetInputLine (char *line); + void AppendDisplayText (char *text, int prop); + void UpdateDisplayAfterOutput (void); + void TerminateDisplay (void); + + // display.c + void PrintPrompt (void); + void ExpressionReady (void); // evaluate.c *************** *** 46,49 **** --- 55,59 ---- int GetSystemVariable (int which); void InitializeSystemVars (void); + void PrintVarList (int filter); // parser_stuff.c *************** *** 65,68 **** --- 75,81 ---- void RemoveHistory (void); + // commands.c + + #endif // End of functions.h Index: parser.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/parser.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** parser.h 27 Feb 2004 02:44:28 -0000 1.2 --- parser.h 4 Mar 2004 00:41:55 -0000 1.3 *************** *** 44,47 **** --- 44,48 ---- void OutputResult (VALUE_TYPE result); void SetResultOutputFormat (int format, VALUE_TYPE value); + void RunCommand (int com); |
|
From: <ho...@us...> - 2004-02-27 03:13:15
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7355/src Modified Files: display.c display_text.c evaluate.c Log Message: Check for ISNAN and ISINF to improve portability So far if they're not available no alternative is used Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** display.c 27 Feb 2004 00:34:07 -0000 1.3 --- display.c 27 Feb 2004 03:04:52 -0000 1.4 *************** *** 199,203 **** if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, "%15.10Lg\n", ResultValue ()); } else { // other base result= ResultValue (); --- 199,203 ---- if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, FORMAT_STRING, ResultValue ()); } else { // other base result= ResultValue (); Index: display_text.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_text.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** display_text.c 27 Feb 2004 02:44:28 -0000 1.2 --- display_text.c 27 Feb 2004 03:04:52 -0000 1.3 *************** *** 70,73 **** --- 70,76 ---- output_text= (char *) malloc (50 + extra_size); sprintf (output_text, FORMAT_STRING, ResultValue ()); + i= 0; + while (output_text[i]==' ') ++i; + strcpy (output_text, output_text + i); } else { // other base result= ResultValue (); Index: evaluate.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/evaluate.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** evaluate.c 27 Feb 2004 02:44:28 -0000 1.11 --- evaluate.c 27 Feb 2004 03:04:52 -0000 1.12 *************** *** 231,235 **** { if (ISINF ((double) value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (isnan ((double) value)) NotifyError (PERROR_NAN, NULL); } --- 231,235 ---- { if (ISINF ((double) value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (ISNAN ((double) value)) NotifyError (PERROR_NAN, NULL); } |
|
From: <ho...@us...> - 2004-02-27 03:13:15
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7355/src/include Modified Files: defines.h Log Message: Check for ISNAN and ISINF to improve portability So far if they're not available no alternative is used Index: defines.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/defines.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** defines.h 27 Feb 2004 02:44:28 -0000 1.3 --- defines.h 27 Feb 2004 03:04:52 -0000 1.4 *************** *** 9,13 **** // format string for output ! #define FORMAT_STRING "%-15.10Lg\n" #define FUN_ABS fabsl --- 9,13 ---- // format string for output ! #define FORMAT_STRING "%15.10Lg\n" #define FUN_ABS fabsl *************** *** 40,44 **** // format string for output ! #define FORMAT_STRING "%-15.10g\n" #define FUN_ABS fabs --- 40,44 ---- // format string for output ! #define FORMAT_STRING "%15.10g\n" #define FUN_ABS fabs *************** *** 73,76 **** --- 73,82 ---- #endif /* not HAVE_ISINF */ + #ifdef HAVE_ISNAN + #define ISNAN(x) isnan ((x)) + #else /* not HAVE_ISNAN */ + #define ISNAN(x) 0 + #endif /* not HAVE_ISNAN */ + // definition of infinity, it depens on what VALUE_TYPE is |
|
From: <ho...@us...> - 2004-02-27 03:13:15
|
Update of /cvsroot/ganc/ganc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7355 Modified Files: config.h.in configure.in Log Message: Check for ISNAN and ISINF to improve portability So far if they're not available no alternative is used Index: config.h.in =================================================================== RCS file: /cvsroot/ganc/ganc/config.h.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** config.h.in 27 Feb 2004 02:44:27 -0000 1.6 --- config.h.in 27 Feb 2004 03:04:52 -0000 1.7 *************** *** 4,10 **** #undef BUILD_GUI ! /* Define to one if isinf function is available */ #undef HAVE_ISINF /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM --- 4,13 ---- #undef BUILD_GUI ! /* Define to 1 if isinf function is available */ #undef HAVE_ISINF + /* Define to 1 if isnan function is available */ + #undef HAVE_ISNAN + /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM Index: configure.in =================================================================== RCS file: /cvsroot/ganc/ganc/configure.in,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** configure.in 27 Feb 2004 02:44:27 -0000 1.20 --- configure.in 27 Feb 2004 03:04:52 -0000 1.21 *************** *** 66,70 **** dnl check math lib has 'isinf' function ! AC_CHECK_LIB([m], [isinf], AC_DEFINE(HAVE_ISINF, 1, [Define to one if isinf function is available]), []) dnl pass BUILD_GUI to c code --- 66,73 ---- dnl check math lib has 'isinf' function ! AC_CHECK_LIB([m], [isinf], AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if isinf function is available]), []) ! ! dnl check math lib has 'isnan' function ! AC_CHECK_LIB([m], [isnan], AC_DEFINE(HAVE_ISNAN, 1, [Define to 1 if isnan function is available]), []) dnl pass BUILD_GUI to c code |
|
From: <ho...@us...> - 2004-02-27 02:52:51
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2928/src Modified Files: display_text.c evaluate.c parser_stuff.c variables.c Log Message: Added considerations about math library that improve portability Index: display_text.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display_text.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** display_text.c 27 Feb 2004 00:34:07 -0000 1.1 --- display_text.c 27 Feb 2004 02:44:28 -0000 1.2 *************** *** 69,73 **** if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, "%-15.10Lg\n", ResultValue ()); } else { // other base result= ResultValue (); --- 69,73 ---- if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); ! sprintf (output_text, FORMAT_STRING, ResultValue ()); } else { // other base result= ResultValue (); Index: evaluate.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/evaluate.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** evaluate.c 4 Feb 2004 02:54:25 -0000 1.10 --- evaluate.c 27 Feb 2004 02:44:28 -0000 1.11 *************** *** 21,25 **** - // // Sets up rad_to_any to perform the right angle conversion --- 21,24 ---- *************** *** 46,92 **** VALUE_TYPE result=(VALUE_TYPE) 0.; ! if (id==FUN_ABS) result= fabsl (arg); ! if (id==FUN_SIN) result= sinl (arg/rad_to_any); ! if (id==FUN_COS) result= cosl (arg/rad_to_any); ! if (id==FUN_TAN) result= tanl (arg/rad_to_any); ! if (id==FUN_ASIN) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ASIN, NULL); ! else result= rad_to_any*asinl (arg); } ! if (id==FUN_ACOS) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ACOS, NULL); ! result= rad_to_any*acosl (arg); } ! if (id==FUN_ATAN) result= rad_to_any*atanl (arg); ! if (id==FUN_SINH) result= sinhl (arg/rad_to_any); ! if (id==FUN_COSH) result= coshl (arg/rad_to_any); ! if (id==FUN_TANH) result= tanhl (arg/rad_to_any); ! if (id==FUN_ASINH) result= rad_to_any*asinhl (arg); ! if (id==FUN_ACOSH) result= rad_to_any*acoshl (arg); ! if (id==FUN_ATANH) result= rad_to_any*atanhl (arg); ! if (id==FUN_EXP) result= expl (arg); ! if (id==FUN_LN) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LN, NULL); ! else result= logl (arg); } ! if (id==FUN_EXP10) result= powl (10, arg); ! if (id==FUN_LOG) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LOG, NULL); ! else result= log10l (arg); } ! if (id==FUN_SQRT) { if (arg<=0.) NotifyError (PERROR_INVALID_ARG_SQRT, NULL); ! else result= sqrtl (arg); } ! if (id==FUN_INT) { ! result= nearbyintl (arg); } ! if (id==FUN_FLOOR) { ! result= floorl (arg); } ! if (id==FUN_CEIL) { ! result= ceill (arg); } CheckNumber (result); --- 45,92 ---- VALUE_TYPE result=(VALUE_TYPE) 0.; ! if (id==FUNID_ABS) result= FUN_ABS (arg); ! if (id==FUNID_SIN) result= FUN_SIN (arg/rad_to_any); ! if (id==FUNID_COS) result= FUN_COS (arg/rad_to_any); ! if (id==FUNID_TAN) result= FUN_TAN (arg/rad_to_any); ! if (id==FUNID_ASIN) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ASIN, NULL); ! else result= rad_to_any*FUN_ASIN (arg); } ! if (id==FUNID_ACOS) { if (arg<(VALUE_TYPE) -1. || arg>(VALUE_TYPE) 1.) NotifyError (PERROR_INVALID_ARG_ACOS, NULL); ! result= rad_to_any*FUN_ACOS (arg); } ! if (id==FUNID_ATAN) result= rad_to_any*FUN_ATAN (arg); ! if (id==FUNID_SINH) result= FUN_SINH (arg/rad_to_any); ! if (id==FUNID_COSH) result= FUN_COSH (arg/rad_to_any); ! if (id==FUNID_TANH) result= FUN_TANH (arg/rad_to_any); ! if (id==FUNID_ASINH) result= rad_to_any*FUN_ASINH (arg); ! if (id==FUNID_ACOSH) result= rad_to_any*FUN_ACOSH (arg); ! if (id==FUNID_ATANH) result= rad_to_any*FUN_ATANH (arg); ! if (id==FUNID_EXP) result= FUN_EXP (arg); ! if (id==FUNID_LN) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LN, NULL); ! else result= FUN_LN (arg); } ! if (id==FUNID_EXP10) result= FUN_EXP10 (10, arg); ! if (id==FUNID_LOG) { if (arg<=0.0) NotifyError (PERROR_INVALID_ARG_LOG, NULL); ! else result= FUN_LOG (arg); } ! if (id==FUNID_SQRT) { if (arg<=0.) NotifyError (PERROR_INVALID_ARG_SQRT, NULL); ! else result= FUN_SQRT (arg); } ! if (id==FUNID_INT) { ! if (FUN_FLOOR (arg) + 0.5 > arg) result= FUN_FLOOR (arg); ! else result= FUN_CEIL (arg); } ! if (id==FUNID_FLOOR) { ! result= FUN_FLOOR (arg); } ! if (id==FUNID_CEIL) { ! result= FUN_CEIL (arg); } CheckNumber (result); *************** *** 162,166 **** value= arg1/arg2; // check if division by zero occured ! if (isinf (value)) NotifyError (PERROR_DIVISION_ZERO, NULL); return value; } --- 162,166 ---- value= arg1/arg2; // check if division by zero occured ! if (ISINF (value)) NotifyError (PERROR_DIVISION_ZERO, NULL); return value; } *************** *** 186,190 **** VALUE_TYPE value; ! value= fmodl (arg1, arg2); return value; } --- 186,190 ---- VALUE_TYPE value; ! value= FUN_MOD (arg1, arg2); return value; } *************** *** 198,202 **** VALUE_TYPE value; ! value= powl (arg1, arg2); CheckNumber (value); return value; --- 198,202 ---- VALUE_TYPE value; ! value= FUN_EXP10 (arg1, arg2); CheckNumber (value); return value; *************** *** 230,235 **** void CheckNumber (VALUE_TYPE value) { ! if (isinf (value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (isnan (value)) NotifyError (PERROR_NAN, NULL); } --- 230,235 ---- void CheckNumber (VALUE_TYPE value) { ! if (ISINF ((double) value)) NotifyError (PERROR_OVERFLOW, NULL); ! if (isnan ((double) value)) NotifyError (PERROR_NAN, NULL); } *************** *** 248,252 **** if (base==10) { // base 10, we can do non integer stuff ! strtod (strnumber, NULL); value= strtod (strnumber, &tail); if (*tail!='\0') { // error parsing number --- 248,252 ---- if (base==10) { // base 10, we can do non integer stuff ! //strtold (strnumber, NULL); value= strtod (strnumber, &tail); if (*tail!='\0') { // error parsing number Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** parser_stuff.c 4 Feb 2004 02:54:32 -0000 1.16 --- parser_stuff.c 27 Feb 2004 02:44:28 -0000 1.17 *************** *** 162,166 **** epos= pos; ! while (isdigit (input[epos]) || isalpha (input[epos]) || input[epos]=='.') ++epos; // we've got an 'entry', lets check it --- 162,167 ---- epos= pos; ! while (isdigit ((int) input[epos]) || isalpha ((int) input[epos]) ! || input[epos]=='.') ++epos; // we've got an 'entry', lets check it *************** *** 171,175 **** (input[epos]=='+' || input[epos]=='-')) { ++epos; ! while (isdigit (input[epos])) ++epos; } // if 'syntactically' opened or closed --- 172,176 ---- (input[epos]=='+' || input[epos]=='-')) { ++epos; ! while (isdigit ((int) input[epos])) ++epos; } // if 'syntactically' opened or closed Index: variables.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/variables.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** variables.c 4 Feb 2004 01:06:38 -0000 1.2 --- variables.c 27 Feb 2004 02:44:28 -0000 1.3 *************** *** 65,69 **** if (isalpha (name[0]) || name[0]=='_') { ! while (isalpha (name[i]) || isdigit (name[i]) || name[i]=='_') ++i; if (name[i]=='\0') ok= 1; } --- 65,69 ---- if (isalpha (name[0]) || name[0]=='_') { ! while (isalpha ((int) name[i]) || isdigit ((int) name[i]) || name[i]=='_') ++i; if (name[i]=='\0') ok= 1; } |
|
From: <ho...@us...> - 2004-02-27 02:52:51
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2928/src/include Modified Files: defines.h parser.h Log Message: Added considerations about math library that improve portability Index: defines.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/defines.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** defines.h 4 Feb 2004 02:54:32 -0000 1.2 --- defines.h 27 Feb 2004 02:44:28 -0000 1.3 *************** *** 2,8 **** --- 2,77 ---- #define __INCLUDED_DEFINES_H__ + + #ifdef HAVE_LONG_DOUBLE_FUNCTIONS + // Basic type for operations in the calculator #define VALUE_TYPE long double + // format string for output + #define FORMAT_STRING "%-15.10Lg\n" + + #define FUN_ABS fabsl + #define FUN_SIN sinl + #define FUN_COS cosl + #define FUN_TAN tanl + #define FUN_ASIN asinl + #define FUN_ACOS acosl + #define FUN_ATAN atanl + #define FUN_SINH sinhl + #define FUN_COSH coshl + #define FUN_TANH tanhl + #define FUN_ASINH asinhl + #define FUN_ACOSH acoshl + #define FUN_ATANH atanhl + #define FUN_EXP expl + #define FUN_LN logl + #define FUN_EXP10 powl + #define FUN_LOG log10l + #define FUN_SQRT sqrtl + #define FUN_FLOOR floorl + #define FUN_CEIL ceill + #define FUN_MOD fmodl + + + #else /* not HAVE_LONG_DOUBLE_FUNCTIONS */ + + // Basic type for operations in the calculator + #define VALUE_TYPE double + + // format string for output + #define FORMAT_STRING "%-15.10g\n" + + #define FUN_ABS fabs + #define FUN_SIN sin + #define FUN_COS cos + #define FUN_TAN tan + #define FUN_ASIN asin + #define FUN_ACOS acos + #define FUN_ATAN atan + #define FUN_SINH sinh + #define FUN_COSH cosh + #define FUN_TANH tanh + #define FUN_ASINH asinh + #define FUN_ACOSH acosh + #define FUN_ATANH atanh + #define FUN_EXP exp + #define FUN_LN log + #define FUN_EXP10 pow + #define FUN_LOG log10 + #define FUN_SQRT sqrt + #define FUN_FLOOR floor + #define FUN_CEIL ceil + #define FUN_MOD fmod + + #endif /* not HAVE_LONG_DOUBLE_FUNCTIONS */ + + + #ifdef HAVE_ISINF + #define ISINF(x) isinf ((x)) + #else /* not HAVE_ISINF */ + #define ISINF(x) 0 + #endif /* not HAVE_ISINF */ + + // definition of infinity, it depens on what VALUE_TYPE is //#define INFINITY HUGE_VALL *************** *** 14,39 **** #define CONSTANT_PI 3.1415926535897932384626433832795029L ! // Definitions to identify functions ! #define FUN_ABS 0 ! #define FUN_SIN 1 ! #define FUN_COS 2 ! #define FUN_TAN 3 ! #define FUN_ASIN 4 ! #define FUN_ACOS 5 ! #define FUN_ATAN 6 ! #define FUN_SINH 7 ! #define FUN_COSH 8 ! #define FUN_TANH 9 ! #define FUN_ASINH 10 ! #define FUN_ACOSH 11 ! #define FUN_ATANH 12 ! #define FUN_EXP 13 ! #define FUN_LN 14 ! #define FUN_EXP10 15 ! #define FUN_LOG 16 ! #define FUN_SQRT 17 ! #define FUN_INT 18 ! #define FUN_FLOOR 19 ! #define FUN_CEIL 20 --- 83,108 ---- #define CONSTANT_PI 3.1415926535897932384626433832795029L ! // ID's of identify functions ! #define FUNID_ABS 0 ! #define FUNID_SIN 1 ! #define FUNID_COS 2 ! #define FUNID_TAN 3 ! #define FUNID_ASIN 4 ! #define FUNID_ACOS 5 ! #define FUNID_ATAN 6 ! #define FUNID_SINH 7 ! #define FUNID_COSH 8 ! #define FUNID_TANH 9 ! #define FUNID_ASINH 10 ! #define FUNID_ACOSH 11 ! #define FUNID_ATANH 12 ! #define FUNID_EXP 13 ! #define FUNID_LN 14 ! #define FUNID_EXP10 15 ! #define FUNID_LOG 16 ! #define FUNID_SQRT 17 ! #define FUNID_INT 18 ! #define FUNID_FLOOR 19 ! #define FUNID_CEIL 20 Index: parser.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/parser.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** parser.h 20 Jan 2004 01:33:40 -0000 1.1 --- parser.h 27 Feb 2004 02:44:28 -0000 1.2 *************** *** 6,9 **** --- 6,13 ---- #define __INCLUDED_PARSER_H__ + #ifdef HAVE_CONFIG_H + #include <config.h> + #endif + #include "defines.h" |
|
From: <ho...@us...> - 2004-02-27 02:52:50
|
Update of /cvsroot/ganc/ganc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2928 Modified Files: config.h.in configure.in Log Message: Added considerations about math library that improve portability Index: config.h.in =================================================================== RCS file: /cvsroot/ganc/ganc/config.h.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** config.h.in 20 Jan 2004 01:33:40 -0000 1.5 --- config.h.in 27 Feb 2004 02:44:27 -0000 1.6 *************** *** 4,10 **** --- 4,20 ---- #undef BUILD_GUI + /* Define to one if isinf function is available */ + #undef HAVE_ISINF + /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM + /* Define to 1 if long double works and has more range or precision than + double. */ + #undef HAVE_LONG_DOUBLE + + /* Define to 1 if long double functions are available */ + #undef HAVE_LONG_DOUBLE_FUNCTIONS + /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O Index: configure.in =================================================================== RCS file: /cvsroot/ganc/ganc/configure.in,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** configure.in 27 Feb 2004 00:34:07 -0000 1.19 --- configure.in 27 Feb 2004 02:44:27 -0000 1.20 *************** *** 22,25 **** --- 22,26 ---- AC_PROG_CC_C_O AC_PROG_CPP + AC_C_LONG_DOUBLE dnl Print debug status *************** *** 56,62 **** dnl if no GUI we need to include math library if test "$BUILD_GUI" = "no"; then ! AC_CHECK_LIB([m], [sin], [], AC_MSG_ERROR(Math library not found)) fi dnl pass BUILD_GUI to c code if test "$BUILD_GUI" = "yes"; then --- 57,71 ---- dnl if no GUI we need to include math library if test "$BUILD_GUI" = "no"; then ! AC_CHECK_LIB([m], [tan], [], AC_MSG_ERROR(Math library not found)) fi + dnl check that math lib has 'long double' math functions + if test "$ac_cv_c_long_double" = "yes"; then + AC_CHECK_LIB([m], [tanl], AC_DEFINE(HAVE_LONG_DOUBLE_FUNCTIONS, 1, [Define to 1 if long double functions are available]), []) + fi + + dnl check math lib has 'isinf' function + AC_CHECK_LIB([m], [isinf], AC_DEFINE(HAVE_ISINF, 1, [Define to one if isinf function is available]), []) + dnl pass BUILD_GUI to c code if test "$BUILD_GUI" = "yes"; then |
|
From: <ho...@us...> - 2004-02-27 00:42:25
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8237/src/include Modified Files: functions.h Log Message: Added possibility to compile without GUI (very basic) Index: functions.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/functions.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** functions.h 3 Feb 2004 21:28:01 -0000 1.10 --- functions.h 27 Feb 2004 00:34:07 -0000 1.11 *************** *** 4,12 **** //#include <stdio.h> #ifdef BUILD_GUI #include <gtk/gtk.h> - #endif ! #include "defines.h" // evaluate.c --- 4,30 ---- //#include <stdio.h> + #include "defines.h" + + #ifdef BUILD_GUI + #include <gtk/gtk.h> ! // display.c ! void PrintPrompt (GtkTextIter *point_iter); ! void TravelEntryHistory (guint keyval); ! void InsertText (char *text); ! void ClearInputLine (void); ! void ExpressionReady (void); ! void SetDisplayGeometryHints (GtkWindow *window); ! void SetDisplayDefaultFont (void); ! ! #else /* not BUILD_GUI */ ! ! // display_text.c ! void TextDisplay (void); ! ! #endif /* not BUILD_GUI */ ! // evaluate.c *************** *** 40,52 **** int GetResultOutputFormat (int format); - // display.c - void PrintPrompt (GtkTextIter *point_iter); - void TravelEntryHistory (guint keyval); - void InsertText (char *text); - void ClearInputLine (void); - void ExpressionReady (void); - void SetDisplayGeometryHints (GtkWindow *window); - void SetDisplayDefaultFont (void); - // history.c void InitializeHistory (void); --- 58,61 ---- |
|
From: <ho...@us...> - 2004-02-27 00:42:25
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8237/src Modified Files: Makefile.am display.c main.c Added Files: display_text.c Log Message: Added possibility to compile without GUI (very basic) --- NEW FILE: display_text.c --- #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <math.h> #include <string.h> #include "include/defines.h" #include "include/functions.h" /*********************************************************************** * * Local Variables * ***********************************************************************/ static const char prompt[]="> "; static char *parse_errors[]={ // Texts of parse errors "unknown variable", // 1 "syntax error", "parse error", "isolated decimal dot", "", // 5 "base out of range", "base conversion error", "invalid argument to LN", "invalid argument to LOG", "invalid argument to factorial", // 10 "invalid argument to SQRT", "invalid argument to ASIN", "invalid argument to ACOS", "division by zero", "overflow", // 15 "NaN", "assignment of constant", "illegal identifier", "illegal constant" }; /*********************************************************************** * * Local Functions * ***********************************************************************/ static char *PreparePrintedResult (void); static int *ExtractSublines (char *line, int *num_sublines); static int LineIsEmpty (char *line); // // prepare text that will be outputed as output // static char *PreparePrintedResult (void) { unsigned long result; int digits, i, d, aux; unsigned int base; char *output_text; int printbase, extra_size=0; base= GetResultOutputFormat (OUTPUT_FORMAT_BASE); printbase= GetResultOutputFormat (OUTPUT_FORMAT_PRINTBASE); if (printbase) extra_size= 3; if (base==10) { // base 10 -> EASY output_text= (char *) malloc (50 + extra_size); sprintf (output_text, "%-15.10Lg\n", ResultValue ()); } else { // other base result= ResultValue (); // calculate number of digits number 'result' takes in base 'base' digits= (int) (log (result)/log (base) + 1); // malloc: 2 for '\n\0' and 2 for safety margin output_text= (char *) malloc (digits + 2 + 2 + extra_size); i= 0; while (result >= base) { d= result % base; if (d<10) output_text[i++]= d + '0'; else output_text[i++]= (d - 10) + 'a'; result/= base; } if (result<10) output_text[i]= result + '0'; else output_text[i]= (result - 10) + 'a'; output_text[i + 1]= '\n'; output_text[i + 2]= '\0'; d= 0; while (d<i) { aux= output_text[i]; output_text[i]= output_text[d]; output_text[d]= aux; --i; d++; } } if (printbase) { i= strlen (output_text) - 1; if (base<10) sprintf (output_text + i, "_%1d\n", base); else sprintf (output_text + i, "_%2d\n", base); } return output_text; } // // Extracts position of sublines (indicated by ';' character) // Returns array with positions of ';' characters, i.e. ends of sublines // and number of sublines found (minimum 1) in 'num_sublines' // array contains at least one element, i.e. end of line // Returned array needs to be freed later // static int *ExtractSublines (char *line, int *num_sublines) { int *sublines; int count, i, j, size; // store size of line size= strlen (line); // find sub-lines embeded in input // run through the input to find ';' characters, store positions in 'sublines' for (i= 0, count= 0; i<size; ++i) if (line[i]==';') ++count; ++count; // at least 1: case of no sub-lines sublines= malloc (count*sizeof (int)); // If some sub-lines are found, store their positions if (count>1) { // there were some ';' for (i= 0, j= 0; i<size; ++i) if (line[i]==';') { sublines[j]= i; ++j; } } // consider end of input as the end of another sub-line // it makes the case with no sub-lines work sublines[count - 1]= size; *num_sublines= count; return sublines; } // // returns 1 if line is empty (0 or more spaces); returns 0 otherwise // static int LineIsEmpty (char *line) { int i; i= strlen (line) - 1; while (i>=0 && line[i]==' ') --i; if (i>=0) return 0; return 1; } #define MAX_LINE_SIZE 200 void TextDisplay (void) { char line[MAX_LINE_SIZE + 1], *extra; int error; int num_sublines, start, i; int *sublines = NULL; char *output_text; int perror, size; while (1) { // read line printf ("%s", prompt); fgets (line, MAX_LINE_SIZE, stdin); line[strlen (line) - 1]= '\0'; // 'exit' entered? if (strcmp (line, "exit")==0) break; // check line is not empty if (LineIsEmpty (line)) continue; // extract sub-lines from input sublines= ExtractSublines (line, &num_sublines); start= 0; // stores starting position of sub-line for (i= 0; i<num_sublines; ++i) { line[sublines[i]]= '\0'; // ignore empty sublines if (LineIsEmpty (line + start)) { start= sublines[i] + 1; continue; } error= ParseTypedExpression (line + start); if (error) { // see if there's any extra text to add to error output perror= ParseError (); extra= ParseErrorExtra (); if (extra==NULL) { size= 20; size+= strlen (parse_errors[perror - 1]); output_text= (char *) malloc (size); //sprintf (output_text, "error: %s\n", parse_errors[perror - 1]); sprintf (output_text, "%s\n", parse_errors[perror - 1]); } else { size= 30; size+= strlen (parse_errors[perror - 1]); size+= strlen (extra); output_text= (char *) malloc (size); //sprintf (output_text, "error: %s: %s\n", parse_errors[perror - 1], extra); sprintf (output_text, "%s: %s\n", parse_errors[perror - 1], extra); free (extra); } } else { // No error, print result output_text= PreparePrintedResult (); } // print output_text (it should already end in '\n') using tag 'result' printf ("%s", output_text); // free memory of output text free (output_text); // set start of next subline start= sublines[i] + 1; } // free memory free (sublines); } } /* Local Variables: c-file-style: "gnu" c-file-offsets: ((case-label . +)) End: */ Index: Makefile.am =================================================================== RCS file: /cvsroot/ganc/ganc/src/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 20 Jan 2004 01:33:40 -0000 1.4 --- Makefile.am 27 Feb 2004 00:34:07 -0000 1.5 *************** *** 10,23 **** ## GUI extra sources and headers if BUILD_GUI ! GUISRC = support.c interface.c callbacks.c GUIHDR = callbacks.h interface.h support.h else ! GUISRC = GUIHDR = endif ! ganc_SOURCES = main.c display.c evaluate.c syntax.y parser_stuff.c \ ! history.c variables.c $(GUISRC) ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ --- 10,23 ---- ## GUI extra sources and headers if BUILD_GUI ! GUISRC = support.c interface.c callbacks.c display.c GUIHDR = callbacks.h interface.h support.h else ! GUISRC = display_text.c GUIHDR = endif ! ganc_SOURCES = main.c evaluate.c syntax.y parser_stuff.c history.c \ ! variables.c $(GUISRC) ganc_LDADD = @LIBS@ @PACKAGE_LIBS@ Index: display.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/display.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** display.c 3 Feb 2004 21:28:01 -0000 1.2 --- display.c 27 Feb 2004 00:34:07 -0000 1.3 *************** *** 42,46 **** /*********************************************************************** * ! * Local Variables * ***********************************************************************/ --- 42,46 ---- /*********************************************************************** * ! * Local Constants * ***********************************************************************/ Index: main.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/main.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main.c 3 Feb 2004 21:28:01 -0000 1.10 --- main.c 27 Feb 2004 00:34:07 -0000 1.11 *************** *** 13,17 **** #include "support.h" #include "interface.h" ! #endif #include "include/defines.h" --- 13,17 ---- #include "support.h" #include "interface.h" ! #endif /* BUILD_GUI */ #include "include/defines.h" *************** *** 31,35 **** GtkTextBuffer *display_text_buffer; GtkWidget *display; - #endif extern GtkTextMark *start_mark; --- 31,34 ---- *************** *** 39,42 **** --- 38,43 ---- extern GtkTextMark *cursor_mark; + #endif /* BUILD_GUI */ + /*********************************************************************** * *************** *** 91,99 **** GtkWidget *window; GtkTextIter start_iter; ! // create interface window= create_window1 (); - // extract widgets //scrollbar1= lookup_widget (window, "vscrollbar1"); --- 92,99 ---- GtkWidget *window; GtkTextIter start_iter; ! // create interface window= create_window1 (); // extract widgets //scrollbar1= lookup_widget (window, "vscrollbar1"); *************** *** 155,159 **** } ! #endif --- 155,159 ---- } ! #endif /* BUILD_GUI */ *************** *** 163,181 **** int main (int argc, char *argv[]) { - - #ifdef BUILD_GUI - // Start gnome - gnome_init (PACKAGE, VERSION, argc, argv); - #endif - // Initialize everything InitializeVars (); ! // set up gtk interface SetUpInterface (); ! // start gtk loop ! gtk_main (); // clean up everything before leaving CleanUp (); --- 163,184 ---- int main (int argc, char *argv[]) { // Initialize everything InitializeVars (); ! ! #ifdef BUILD_GUI ! ! // Start gnome and gtk stuff ! gnome_init (PACKAGE, VERSION, argc, argv); SetUpInterface (); + gtk_main (); // start gtk loop + + #else /* not BUILD_GUI */ ! TextDisplay (); ! ! #endif /* not BUILD_GUI */ + // clean up everything before leaving CleanUp (); |
|
From: <ho...@us...> - 2004-02-27 00:42:25
|
Update of /cvsroot/ganc/ganc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8237 Modified Files: configure.in Log Message: Added possibility to compile without GUI (very basic) Index: configure.in =================================================================== RCS file: /cvsroot/ganc/ganc/configure.in,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** configure.in 3 Feb 2004 21:28:01 -0000 1.18 --- configure.in 27 Feb 2004 00:34:07 -0000 1.19 *************** *** 14,18 **** AC_ARG_ENABLE([gui], AC_HELP_STRING([--disable-gui], [disable GUI (GUI is enabled by default)]), [BUILD_GUI=$enableval], [BUILD_GUI=yes]) ! BUILD_GUI=yes dnl C stuff --- 14,18 ---- AC_ARG_ENABLE([gui], AC_HELP_STRING([--disable-gui], [disable GUI (GUI is enabled by default)]), [BUILD_GUI=$enableval], [BUILD_GUI=yes]) ! dnl BUILD_GUI=yes dnl C stuff |
|
From: <ho...@us...> - 2004-02-26 23:25:43
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24658/src Removed Files: reader_communication.c reader_stuff.c terminal_stuff.c terminal_stuff_vte.c Log Message: Eliminated obsolete files from CVS repository --- reader_communication.c DELETED --- --- reader_stuff.c DELETED --- --- terminal_stuff.c DELETED --- --- terminal_stuff_vte.c DELETED --- |
|
From: <ho...@us...> - 2004-02-04 03:13:33
|
Update of /cvsroot/ganc/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3870 Modified Files: download.php index.php local_variables.php Log Message: Added bug fix release 0.8.2 Index: download.php =================================================================== RCS file: /cvsroot/ganc/web/download.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** download.php 4 Feb 2004 02:39:08 -0000 1.3 --- download.php 4 Feb 2004 03:11:13 -0000 1.4 *************** *** 29,32 **** --- 29,35 ---- </p> <ul> + <li>Stable version <strong>0.8.2</strong>: + <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.8.2.tar.gz?download">ganc-0.8.2.tar.gz</a></li> + <li>Stable version <strong>0.8</strong>: <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.8.tar.gz?download">ganc-0.8.tar.gz</a></li> Index: index.php =================================================================== RCS file: /cvsroot/ganc/web/index.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.php 4 Feb 2004 02:39:08 -0000 1.3 --- index.php 4 Feb 2004 03:11:13 -0000 1.4 *************** *** 20,27 **** <ul class="news"> <li>3rd Feb 2004 <br /> <em>ganc-0.8 released</em></li> ! Brand new ganc release. <br /> ! With this version ganc becomes pure gtk2. <br /> ! It doesn't use readline and libzvt2 anymore so it should be a lot easier to install for a lot of people. And it looks way nicer thanks to the wonderful gtk2 widget GtkTextView. <li>13th Dec 2003 <br /> --- 20,32 ---- <ul class="news"> <li>3rd Feb 2004 <br /> + <em>ganc-0.8.2 released</em></li> + Just a quick bug fix from 0.8<br /> + See ChangeLog for details + + <li>3rd Feb 2004 <br /> <em>ganc-0.8 released</em></li> ! Brand new ganc release. <br /> ! With this version ganc becomes pure gtk2. <br /> ! It doesn't use readline and libzvt2 anymore so it should be a lot easier to install for a lot of people. And it looks way nicer thanks to the wonderful gtk2 widget GtkTextView. <li>13th Dec 2003 <br /> Index: local_variables.php =================================================================== RCS file: /cvsroot/ganc/web/local_variables.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** local_variables.php 4 Feb 2004 02:39:08 -0000 1.2 --- local_variables.php 4 Feb 2004 03:11:13 -0000 1.3 *************** *** 1,5 **** <!-- define local variables --> <?php ! $current_version="0.8"; $home_class=""; --- 1,5 ---- <!-- define local variables --> <?php ! $current_version="0.8.2"; $home_class=""; |
|
From: <ho...@us...> - 2004-02-04 02:56:50
|
Update of /cvsroot/ganc/ganc/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv876/src Modified Files: evaluate.c parser_stuff.c syntax.y Log Message: Added 3 new functions: INT, FLOOR, CEIL Index: evaluate.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/evaluate.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** evaluate.c 20 Jan 2004 01:33:40 -0000 1.9 --- evaluate.c 4 Feb 2004 02:54:25 -0000 1.10 *************** *** 81,84 **** --- 81,93 ---- else result= sqrtl (arg); } + if (id==FUN_INT) { + result= nearbyintl (arg); + } + if (id==FUN_FLOOR) { + result= floorl (arg); + } + if (id==FUN_CEIL) { + result= ceill (arg); + } CheckNumber (result); Index: parser_stuff.c =================================================================== RCS file: /cvsroot/ganc/ganc/src/parser_stuff.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** parser_stuff.c 4 Feb 2004 01:06:38 -0000 1.15 --- parser_stuff.c 4 Feb 2004 02:54:32 -0000 1.16 *************** *** 73,77 **** "exp10", //15 "log", ! "sqrt", //17 "" }; --- 73,80 ---- "exp10", //15 "log", ! "sqrt", ! "int", ! "floor", ! "ceil", //20 "" }; Index: syntax.y =================================================================== RCS file: /cvsroot/ganc/ganc/src/syntax.y,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** syntax.y 4 Feb 2004 01:06:38 -0000 1.7 --- syntax.y 4 Feb 2004 02:54:32 -0000 1.8 *************** *** 12,16 **** } ! %token <name> ENTRY %token <id> FUNCTION %token <name> VARIABLE --- 12,16 ---- } ! %token <name> ENTRY %token <id> FUNCTION %token <name> VARIABLE *************** *** 88,91 **** --- 88,92 ---- format_token: '_' exp { SetResultOutputFormat (OUTPUT_FORMAT_BASE, $2); } | '_' { SetResultOutputFormat (OUTPUT_FORMAT_PRINTBASE, 1); } + /* | ENTRY { printf ("format entry: %s\n", $1); } */ ; |
|
From: <ho...@us...> - 2004-02-04 02:56:50
|
Update of /cvsroot/ganc/ganc/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv876/src/include Modified Files: defines.h Log Message: Added 3 new functions: INT, FLOOR, CEIL Index: defines.h =================================================================== RCS file: /cvsroot/ganc/ganc/src/include/defines.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** defines.h 20 Jan 2004 01:33:40 -0000 1.1 --- defines.h 4 Feb 2004 02:54:32 -0000 1.2 *************** *** 33,36 **** --- 33,39 ---- #define FUN_LOG 16 #define FUN_SQRT 17 + #define FUN_INT 18 + #define FUN_FLOOR 19 + #define FUN_CEIL 20 |
Update of /cvsroot/ganc/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30872 Modified Files: download.php ganc.css index.php local_variables.php right_frame.php Added Files: documentation.php Removed Files: news.php Log Message: Moved 'news.php' to 'index.php' and added 'documentation.php' that is basically old 'index.php' --- NEW FILE: documentation.php --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Home - ganc</title> <link rel="Stylesheet" href="ganc.css" type="text/css" media="screen" /> <script src="scripts/x.js" type="text/javascript"></script> <script src="scripts/adjust-columns.js" type="text/javascript"></script> </head> <body> <!-- include some local_variables --> <?php include 'local_variables.php' ?> <?php $documentation_class="active" ?> <!---------------------------- Left frame -----------------------------> <div id="leftframe"> <div id="leftframe-content"> <!-- this id is necessary for the javascript --> <h2>Documentation</h2> <hr /> <p> ganc is a <strong>G</strong>nome-based <strong>A</strong>lgebraic <strong>N</strong>otation <strong>C</strong>alculator. <br /> Just a very very useful and simple algebraic calculator. But then again, not so simple. </p> <p> Have you ever done some simple calculation like adding a bunch of numbers. Then you made a mistake and all the numbers you'd typed so far got lost. Or maybe you finished, got your result and wondered if you made a mistake typing. Is the result correct? Well, I'm affraid the only way to know is do it again and hope you get the same result. </p> <p> Or maybe you were programing and wanted to transform that ugly hexadecimal or binary number into something more meaningful. Or viceversa. </p> <p>That's where ganc comes in. </p> <p> ganc has a very simple syntax. There's no learning curve. If you want to add two plus two you just type '2 + 2' and that's it! It can also handle more complicated stuff involving several expressions in the same line, functions, implicit product, variables, numbers in different bases, bitwise operations, logical operations, etc ... It even allows C-style in-line variable definition.<br /> </p> <p> The format for any expression entered in ganc is:<br /><br /> <strong>expression [:: format [, format, ...]]</strong> </p> <p> <em>expression</em> is just a regular mathematical expression. <br /> You can use operations such as: <ul> <li>arithmetics operators: <strong><pre>+ - * /</pre> </strong></li> <li>logical operators: <strong><pre>&& || != == > < >= <= </pre> </strong></li> <li>bitwise operators: <strong><pre>& | ~ ^| </pre></strong></li> <li>functions: <strong><pre>sin cos exp log ...</pre> </strong></li> </ul> </p> <p> <em>format</em> is one or more format identifiers separated by commas<br /> So far the only format identifiers supported are: <ul> <li><em>_number</em>: output will be expressed in base <em>number</em></li> <li><em>_</em>: write output result in base format: <em>number_base</em></li> </ul> </p> <p> Some examples of valid ganc expressions are: <table cellspacing="5"> <tr><td>2 + 2 * 3</td><td><em>precedence is handled adequately (= 8)<em></td></tr> <tr><td>sin 45</td><td><em>trigonometrical functions<em></td></tr> <tr><td>2 sin 45</td><td><em>implicit product</em></td></tr> <tr><td>a= 2 + 2 * 3</td><td><em>variable asignment</em></td></tr> <tr><td>2*a + 2a</td><td><em>variable use</em></td></tr> <tr><td>c= 2*b= a + 2a</td><td><em>in-line variable asignment (b=a + 2a and c= 2*(a + 2a))</em></td></tr> <tr><td>2 + 3; b= 1 - 2; 2b</td><td><em>several expressions at the same time</em></td></tr> <tr><td>1b5_16</td><td><em>hexadecimal number (base 16)</em></td></tr> <tr><td>3vgt_32; 1001_2</td><td><em>base 32 and binary</em></td></tr> <tr><td>23 :: _16</td><td><em>number 23 expressed in base 16</em></td></tr> <tr><td>f_16 & 1101_2</td><td><em>bitwise 'and' operation</em></td></tr> </table> <!-- <ul> <li><span>2 + 2 * 3</span><em>precedence is handled adequately (= 8)</em></li> <li><span>sin 45</span><em>trigonometrical functions</em></li> <li><span>2 sin 45</span><em>implicit product</em></li> <li><span>a= 2 + 2 * 3</span><em>variable asignment</em></li> <li><span>2*a + 2a</span><em>variable use</em></li> <li><span>c= 2*b= a + 2a</span><em>in-line variable asignment (b=a + 2a and c= 2*(a + 2a))</em></li> <li><span>2 + 3; b= 1 - 2; 2b</span><em>several expressions at the same time</em></li> <li><span>1b5_16</span><em>hexadecimal number (base 16)</em></li> <li><span>3vgt_32; 1001_2</span><em>base 32 and binary</em></li> <li><span>23 :: _16</span><em>number 23 expressed in base 16</em></li> <li><span>f_16 & 1101_2</span><em>bitwise 'and' operation</em></li> </ul> --> </p> <p> ganc also features a keypad so you don't have to type if you don't feel like it. You can achieve the same results just using your mouse. </p> </div> </div> <!---------------------------- Right frame -----------------------------> <?php include 'right_frame.php' ?> <!-------------------------------- Footer --------------------------------> <div id="footer"> <hr /> </div> </body> </html> Index: download.php =================================================================== RCS file: /cvsroot/ganc/web/download.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** download.php 4 Feb 2004 01:49:14 -0000 1.2 --- download.php 4 Feb 2004 02:39:08 -0000 1.3 *************** *** 29,41 **** </p> <ul> <li>Stable version <strong>0.7</strong>: ! <ul> ! <li>Source tarball: <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.7.tar.gz?download">ganc-0.7.tar.gz</a></li> ! </ul> <li>Stable version <strong>0.6</strong>: ! <ul> ! <li>Source tarball: <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.6.tar.gz?download">ganc-0.6.tar.gz</a></li> ! </ul> ! </li> <li>CVS at SourceForge.net: <ul> --- 29,41 ---- </p> <ul> + <li>Stable version <strong>0.8</strong>: + <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.8.tar.gz?download">ganc-0.8.tar.gz</a></li> + <li>Stable version <strong>0.7</strong>: ! <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.7.tar.gz?download">ganc-0.7.tar.gz</a></li> ! <li>Stable version <strong>0.6</strong>: ! <a href="http://prdownloads.sourceforge.net/ganc/ganc-0.6.tar.gz?download">ganc-0.6.tar.gz</a></li> ! <li>CVS at SourceForge.net: <ul> Index: ganc.css =================================================================== RCS file: /cvsroot/ganc/web/ganc.css,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ganc.css 4 Feb 2004 01:49:14 -0000 1.2 --- ganc.css 4 Feb 2004 02:39:08 -0000 1.3 *************** *** 84,88 **** /* emphasis inside list */ ul em { ! padding-left: 30%; /* padding-left: 12em;*/ } --- 84,88 ---- /* emphasis inside list */ ul em { ! /* padding-left: 30%; */ /* padding-left: 12em;*/ } Index: index.php =================================================================== RCS file: /cvsroot/ganc/web/index.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** index.php 4 Feb 2004 01:49:14 -0000 1.2 --- index.php 4 Feb 2004 02:39:08 -0000 1.3 *************** *** 9,79 **** <body> <!-- include some local_variables --> ! <?php include 'local_variables.php' ?> ! <?php $home_class="active" ?> <!---------------------------- Left frame -----------------------------> <div id="leftframe"> ! <div id="leftframe-content"> <!-- this id is necessary for the javascript --> ! <h2>ganc</h2> <hr /> ! <p> ! ganc is a <strong>G</strong>nome-based <strong>A</strong>lgebraic <strong>N</strong>otation <strong>C</strong>alculator. <br /> ! Just a very very useful and simple algebraic calculator. But then again, not so simple. ! </p> ! <p> ! Have you ever done some simple calculation like adding a bunch of numbers. ! Then you made a mistake and all the numbers you'd typed so far got lost. ! Or maybe you finished, got your result and wondered if you made a mistake typing. ! Is the result correct? Well, I'm affraid the only way to know is do it again and ! hope you get the same result. ! </p> ! <p> ! Or maybe you were programing and wanted to transform that ugly hexadecimal or binary number into ! something more meaningful. Or viceversa. ! </p> ! <p>That's where ganc comes in. </p> ! <p> ! ganc has a very simple syntax. There's no learning curve. If you want to add two plus two ! you just type '2 + 2' and that's it! ! It can also handle more complicated stuff involving several expressions in the same line, ! functions, implicit product, variables, numbers in different bases, bitwise operations, ! logical operations, etc ... It even allows C-style in-line variable definition.<br /> ! Some examples of valid ganc expressions are: ! <table cellspacing="5"> ! <tr><td>2 + 2 * 3</td><td><em>precedence is handled adequately (= 8)<em></td></tr> ! <tr><td>sin 45</td><td><em>trigonometrical functions<em></td></tr> ! <tr><td>2 sin 45</td><td><em>implicit product</em></td></tr> ! <tr><td>a= 2 + 2 * 3</td><td><em>variable asignment</em></td></tr> ! <tr><td>2*a + 2a</td><td><em>variable use</em></td></tr> ! <tr><td>c= 2*b= a + 2a</td><td><em>in-line variable asignment (b=a + 2a and c= 2*(a + 2a))</em></td></tr> ! <tr><td>2 + 3; b= 1 - 2; 2b</td><td><em>several expressions at the same time</em></td></tr> ! <tr><td>1b5_16</td><td><em>hexadecimal number (base 16)</em></td></tr> ! <tr><td>3vgt_32; 1001_2</td><td><em>base 32 and binary</em></td></tr> ! <tr><td>23 :: _16</td><td><em>number 23 expressed in base 16</em></td></tr> ! <tr><td>f_16 & 1101_2</td><td><em>bitwise 'and' operation</em></td></tr> ! </table> ! <!-- ! <ul> ! <li><span>2 + 2 * 3</span><em>precedence is handled adequately (= 8)</em></li> ! <li><span>sin 45</span><em>trigonometrical functions</em></li> ! <li><span>2 sin 45</span><em>implicit product</em></li> ! <li><span>a= 2 + 2 * 3</span><em>variable asignment</em></li> ! <li><span>2*a + 2a</span><em>variable use</em></li> ! <li><span>c= 2*b= a + 2a</span><em>in-line variable asignment (b=a + 2a and c= 2*(a + 2a))</em></li> ! <li><span>2 + 3; b= 1 - 2; 2b</span><em>several expressions at the same time</em></li> ! <li><span>1b5_16</span><em>hexadecimal number (base 16)</em></li> ! <li><span>3vgt_32; 1001_2</span><em>base 32 and binary</em></li> ! <li><span>23 :: _16</span><em>number 23 expressed in base 16</em></li> ! <li><span>f_16 & 1101_2</span><em>bitwise 'and' operation</em></li> ! </ul> ! --> ! </p> ! <p> ! ganc also features a keypad so you don't have to type if you don't feel like it. You can achieve the same results ! just using your mouse. ! </p> ! <p> ! ganc adds the power and complexity of an algebraic calculator to the simplicity of a regular calculator. ! </p> </div> </div> --- 9,43 ---- <body> <!-- include some local_variables --> ! <?php ! include 'local_variables.php'; ! $home_class="active"; ! ?> <!---------------------------- Left frame -----------------------------> <div id="leftframe"> ! <div id="leftframe-content"> ! <h2>ganc - News</h2> <hr /> ! <ul class="news"> ! <li>3rd Feb 2004 <br /> ! <em>ganc-0.8 released</em></li> ! Brand new ganc release. <br /> ! With this version ganc becomes pure gtk2. <br /> ! It doesn't use readline and libzvt2 anymore so it should be a lot easier to install for a lot of people. And it looks way nicer thanks to the wonderful gtk2 widget GtkTextView. ! ! <li>13th Dec 2003 <br /> ! <em>ganc-0.7 released</em></li> ! A new hot release right out of the oven. Check it out in ! the download page. ! <li>21st Nov 2003<br /> ! <em>ganc's web page got updated</em></li> ! ganc's web page got a major makeover ! ! <li>19th Nov 2003<br /> ! <em>ganc goes on CVS</em></li> ! ganc's source code is in CVS!<br /> ! You can get it at SourceForge.net ! ! </ul> </div> </div> Index: local_variables.php =================================================================== RCS file: /cvsroot/ganc/web/local_variables.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** local_variables.php 17 Dec 2003 00:21:22 -0000 1.1 --- local_variables.php 4 Feb 2004 02:39:08 -0000 1.2 *************** *** 1,8 **** <!-- define local variables --> <?php ! $current_version="0.7"; $home_class=""; ! $news_class=""; $screenshots_class=""; $download_class=""; --- 1,8 ---- <!-- define local variables --> <?php ! $current_version="0.8"; $home_class=""; ! $documentation_class=""; $screenshots_class=""; $download_class=""; Index: right_frame.php =================================================================== RCS file: /cvsroot/ganc/web/right_frame.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** right_frame.php 4 Feb 2004 01:49:14 -0000 1.2 --- right_frame.php 4 Feb 2004 02:39:08 -0000 1.3 *************** *** 7,11 **** </p> <p class="<?php echo "$home_class" ?>"><a href="http://ganc.sourceforge.net">Home</a></p> ! <p class="<?php echo "$news_class" ?>"><a href="news.php">News</a></p> <p class="<?php echo "$screenshots_class" ?>"><a href="screenshots.php">Screenshots</a></p> <p class="<?php echo "$download_class" ?>"><a href="download.php">Download</a></p> --- 7,11 ---- </p> <p class="<?php echo "$home_class" ?>"><a href="http://ganc.sourceforge.net">Home</a></p> ! <p class="<?php echo "$documentation_class" ?>"><a href="documentation.php">Documentation</a></p> <p class="<?php echo "$screenshots_class" ?>"><a href="screenshots.php">Screenshots</a></p> <p class="<?php echo "$download_class" ?>"><a href="download.php">Download</a></p> --- news.php DELETED --- |