[Mistat-cvs] mistat/src .indent.pro,NONE,1.1 Makefile.in,1.11,1.12 cmdline.c,1.8,1.9 cmdline.h,1.6,1
Status: Pre-Alpha
Brought to you by:
bikepunk005
|
From: Mike H. B. <bik...@us...> - 2004-06-09 17:00:37
|
Update of /cvsroot/mistat/mistat/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30123/src Modified Files: Makefile.in cmdline.c cmdline.h error.c error.h file_ops.c file_ops.h main.c main.h menu.c menu.h mistat.ggo output.c output.h statistics.c statistics.h system.h Added Files: .indent.pro Removed Files: mystyle.c Log Message: Now with linear support. Added a test function--large sig digits (from float.h) and a few extra functions. Updated all headers. Added NIST data files to data. Index: output.h =================================================================== RCS file: /cvsroot/mistat/mistat/src/output.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** output.h 30 May 2004 16:36:15 -0000 1.15 --- output.h 9 Jun 2004 17:00:05 -0000 1.16 *************** *** 1,34 **** ! /* functions in output.c for mistat ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! /*output.h*/ ! /*USAGE: Need for number of variables for analysis, or to call for output.*/ #ifndef OUTPUT_H ! #define OUTPUT_H ! #include "system.h" /* For bool and c_v variables. */ /* ! * Defines */ ! #define MCOL 60 /* Maximum columin width is 60. */ ! #define MROW 100 /* Maximum number of rows is 100. */ ! #define MLABEL 30 /* Maximum statistics label. */ /* --- 1,37 ---- ! /* Functions in output.c for mistat ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! ! /* ! * output.h USAGE: Need for number of variables for analysis, or to call for output. ! */ ! #ifndef OUTPUT_H ! # define OUTPUT_H ! # include "system.h" /* For bool and c_v variables. */ /* ! * Defines */ ! # define MCOL 60 /* Maximum columin width is 60. */ ! # define MROW 100 /* Maximum number of rows is 100. */ ! # define MLABEL 30 /* Maximum statistics label. */ /* *************** *** 36,50 **** */ ! /* output_main ! * USAGE: supply v (variables for analysis) and statistical routine. ! * RETURN: true if succesful. */ bool output_main (int v[], int routine, int stats_to_do); /* ! * Extern Data */ ! extern int Num_Vars; /*Number of variables to analyze. */ #endif ! /*Here ends output.h.*/ --- 39,53 ---- */ ! /* ! * USAGE: supply v (variables for analysis) and statistical routine. ! * RETURN: true if succesful. */ bool output_main (int v[], int routine, int stats_to_do); /* ! * Extern Data */ ! extern int Num_Vars; /* Number of variables to analyze. */ #endif ! /* Here ends output.h. */ --- NEW FILE: .indent.pro --- +blank-lines-after-procedures +brace-indent0 /*0 from 2*/ +braces-after-if-line +braces-after-struct-decl-line +break-before-boolean-operator +continuation-indentation4 /**/ +continue-at-parentheses +declaration-indentation2 +dont-cuddle-else +dont-format-comments +dont-format-first-column-comments +else-endif-column1 +ignore-newlines /**/ +indent-level4/**/ +leave-optional-blank-lines +leave-preprocessor-space /**/ +line-length80 /**/ +no-blank-lines-after-commas +no-blank-lines-after-declarations +no-tabs /**/ +preprocessor-indentation2 /**/ +procnames-start-lines +space-after-cast +space-after-procedure-calls +tab-size4 /**/ Index: file_ops.h =================================================================== RCS file: /cvsroot/mistat/mistat/src/file_ops.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** file_ops.h 29 May 2004 19:59:23 -0000 1.11 --- file_ops.h 9 Jun 2004 17:00:05 -0000 1.12 *************** *** 1,38 **** ! /* Header for file_ops.c in mistat. ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! /*file_ops.h*/ ! /*USAGE: Doing anything with a file, also when using Nrows or Columns.*/ #ifndef FILE_OPS_H ! #define FILE_OPS_H /* ! * Defines */ ! #define MAXLINE 50000 /*Current limit of max. data file lines. */ ! /*Current limit of max. data file rows (cases) ! * Based on max. number in Excel * 2 + 1. */ ! #define MAXROWS 131073 ! #define MAXCOLS 400 /*Current limit of max. data file cols (variables) */ ! /* Defines used for Data_Type. */ ! #define INT_DATA 1 ! #define FLOAT_DATA 2 ! #define CHAR_DATA 3 /* --- 1,43 ---- ! /* Header for file_ops.c in mistat. ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! ! /* ! * file_ops.h USAGE: Doing anything with a file, also when using Nrows or Columns. ! */ ! #ifndef FILE_OPS_H ! # define FILE_OPS_H /* ! * Defines */ ! # define MAXLINE 50000 /* Current limit of max. data file lines. */ ! /* ! * Current limit of max. data file rows (cases)Based on max. number in Excel * 2 + 1. ! */ ! # define MAXROWS 131073 ! # define MAXCOLS 400 /* Current limit of max. data file cols (variables). */ ! ! /* Defines used for Data_Type. */ ! # define INT_DATA 1 ! # define FLOAT_DATA 2 ! # define CHAR_DATA 3 /* *************** *** 50,63 **** /* ! * Extern data */ ! extern int Nrows; /*number of rows in data file */ ! extern int Columns; /*number of columns in a data file */ /* ! * Data_Type is an array containing the type of data for each respective variable. ! * 1 is int, 2 is float, 3 is character. */ extern int Data_Type[]; #endif ! /*Here ends file_ops.h.*/ --- 55,68 ---- /* ! * Extern data */ ! extern int Nrows; /* Number of rows in data file. */ ! extern int Columns; /* Number of columns in a data file. */ /* ! * Data_Type is an array containing the type of data for each respective variable. ! * 1 is int, 2 is float, 3 is character. */ extern int Data_Type[]; #endif ! /* Here ends file_ops.h. */ Index: mistat.ggo =================================================================== RCS file: /cvsroot/mistat/mistat/src/mistat.ggo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mistat.ggo 18 Feb 2004 05:43:04 -0000 1.2 --- mistat.ggo 9 Jun 2004 17:00:05 -0000 1.3 *************** *** 21,25 **** #Input changes below into resulting cmdline.c file. ! purpose "mistat is a statistical program based on statist.\nCopyright (C) 2003 Mike H. Benton\nmistat comes with NO WARRANTY, \nto the extent permitted by law. \nYou may redistribute copies of mistat\nunder the terms of the GNU General Public License. \nFor more information about these matters, \nsee the files named COPYING. \n" #options --- 21,25 ---- #Input changes below into resulting cmdline.c file. ! purpose "mistat is a statistical program based on statist.\nCopyright (C) 2004 Mike H. Benton\nmistat comes with NO WARRANTY, \nto the extent permitted by law. \nYou may redistribute copies of mistat\nunder the terms of the GNU General Public License. \nFor more information about these matters, \nsee the files named COPYING. \n" #options *************** *** 29,33 **** option "log" l "Write results to statist.log" flag off option "nofile" n "Do not read data file on startup.\n\t\t\tData file must be specified from menu." flag off ! #NOTE: chage cmdline.c for error check of only one file! # if (optind < argc) { --- 29,33 ---- option "log" l "Write results to statist.log" flag off option "nofile" n "Do not read data file on startup.\n\t\t\tData file must be specified from menu." flag off ! option "test" t "Suppy testing options.\n\t\tIncrease number of sig. digits." flag off #NOTE: chage cmdline.c for error check of only one file! # if (optind < argc) { Index: error.h =================================================================== RCS file: /cvsroot/mistat/mistat/src/error.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** error.h 29 May 2004 18:22:23 -0000 1.7 --- error.h 9 Jun 2004 17:00:05 -0000 1.8 *************** *** 1,28 **** ! /*Error handling header for error.c in mistat. ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! /*error.h*/ ! /*USAGE: Error handling. Not much use yet.*/ #ifndef ERROR_H ! #define ERROR_H /* ! * Prototypes */ void set_signals (void); --- 1,31 ---- ! /* Error handling header for error.c in mistat. ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! ! /* ! * error.h USAGE: Error handling. Not much use yet. ! */ ! #ifndef ERROR_H ! # define ERROR_H /* ! * Prototypes */ void set_signals (void); *************** *** 33,38 **** void signal_segv (int sig_value); void signal_term (int sig_value); - /*int my_gsl_error_check (int status);*/ #endif ! /*Here ends error.h.*/ --- 36,40 ---- void signal_segv (int sig_value); void signal_term (int sig_value); #endif ! /* Here ends error.h. */ Index: file_ops.c =================================================================== RCS file: /cvsroot/mistat/mistat/src/file_ops.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** file_ops.c 29 May 2004 19:59:23 -0000 1.12 --- file_ops.c 9 Jun 2004 17:00:05 -0000 1.13 *************** *** 1,28 **** ! /* File operations for mistat. ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! /* file_ops.c */ #include <errno.h> #include <stdio.h> #include <stdlib.h> ! #include <ctype.h> /* Conversions and class testing. */ #include <string.h> --- 1,30 ---- ! /* File operations for mistat. ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ ! /* ! * file_ops.c USAGE: getting there. ! */ #include <errno.h> #include <stdio.h> #include <stdlib.h> ! #include <ctype.h> /* Conversions and class testing. */ #include <string.h> *************** *** 32,44 **** ! int Nrows; /*The number of rows in the data file */ ! int Columns; /*The number of Columns in the data file */ ! int Data_Type[MAXCOLS]; /* The type of data for each variable. */ void printline (FILE * fp); /* ! * Close file *file_name pointed by to *fp ! * No return */ void --- 34,46 ---- ! int Nrows; /* The number of rows in the data file. */ ! int Columns; /* The number of Columns in the data file. */ ! int Data_Type[MAXCOLS]; /* The type of data for each variable. */ void printline (FILE * fp); /* ! * Close file *file_name pointed by to *fp. ! * No return. */ void *************** *** 46,60 **** { ! if (fclose (fp) == 0) ! printf ("\t\t%s closed successfully!\n", file_name); ! else ! printf ("\t\t%s did not close\n", file_name); } /* ! * Opens file_name as a file. ! * Returns a file pointer. * FIXME: need to add type of flag input */ --- 48,62 ---- { ! if (fclose (fp) == 0) ! printf ("\t\t%s closed successfully!\n", file_name); ! else ! printf ("\t\t%s did not close\n", file_name); } /* ! * Opens file_name as a file. ! * Returns a file pointer. * FIXME: need to add type of flag input */ *************** *** 62,99 **** open_file (char *file_name, int open_mode) { ! FILE *fp; ! if (open_mode == 1) ! fp = fopen (file_name, "r"); ! else if (open_mode == 2) ! fp = fopen (file_name, "w"); ! else if (open_mode == 3) ! fp = fopen (file_name, "w+"); ! else { ! printf ("ERROR: invalid open_mode in open_file!\n"); ! exit (EXIT_FAILURE); } ! if (fp == NULL) ! fprintf (stderr, "\t\tCannot open %s!\n\t\tERROR: %s!\n", file_name, ! strerror (errno)); ! else ! printf ("\t\t%s opened successfully!\n", file_name); ! return fp; } /* ! * Returns void. ! * Counts the number of cases, and sets VARIABLE_TYPE. ! * Calls fgetline () and getwords(). * ! * FIXME: Need to set blank to missing. Need to define missing! Reads data that is not there, as above * FIXME: Reads . as a line!!!!! */ --- 64,101 ---- open_file (char *file_name, int open_mode) { ! FILE *fp; ! if (open_mode == 1) ! fp = fopen (file_name, "r"); ! else if (open_mode == 2) ! fp = fopen (file_name, "w"); ! else if (open_mode == 3) ! fp = fopen (file_name, "w+"); ! else { ! printf ("ERROR: invalid open_mode in open_file!\n"); ! exit (EXIT_FAILURE); } ! if (fp == NULL) ! fprintf (stderr, "\t\tCannot open %s!\n\t\tERROR: %s!\n", file_name, ! strerror (errno)); ! else ! printf ("\t\t%s opened successfully!\n", file_name); ! return fp; } /* ! * Returns void. ! * Counts the number of cases, and sets VARIABLE_TYPE. ! * Calls fgetline () and getwords(). * ! * FIXME: Need to set blank to missing. Need to define missing! Reads data that is not there, as above * FIXME: Reads . as a line!!!!! */ *************** *** 101,153 **** read_data_file (FILE * file_name) { ! static FILE *temp_fp; /*used for passing between read functions */ ! char line[MAXLINE]; ! char *words[MAXLINE]; ! int n; ! temp_fp = file_name; ! Nrows = 0; ! Columns = 0; ! if (file_name == NULL) { ! fprintf (stderr, ! "\n\nDatafile is not open for some reason?\n\nFatal ERROR: %s\n\n", ! strerror (errno)); ! Nrows = Columns = -1; /* Set to -1 for error checks elsewhere. */ } ! else { ! while (fgetline (temp_fp, line, MAXLINE) != EOF) { ! if (Nrows >= MAXROWS) { ! fprintf (stderr, ! "ERROR: Too many rows in read_data_file. ERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! n = getwords (line, words, MAXCOLS); ! if (Columns < n) ! Columns = n; ! Nrows++; } } ! printf ! ("\nThere are %d rows (cases)\n\tand %d Columns (variables) in the data set\n", ! Nrows, Columns); } /* ! * getwords() ! * return the number of words from fgetline() ! * replaced \0 with \t in parts */ --- 103,154 ---- read_data_file (FILE * file_name) { ! static FILE *temp_fp; /*used for passing between read functions */ ! char line[MAXLINE]; ! char *words[MAXLINE]; ! int n; ! temp_fp = file_name; ! Nrows = 0; ! Columns = 0; ! if (file_name == NULL) { ! fprintf (stderr, ! "\n\nDatafile is not open for some reason?\n\nFatal ERROR: %s\n\n", ! strerror (errno)); ! Nrows = Columns = -1; /* Set to -1 for error checks elsewhere. */ } ! else { ! while (fgetline (temp_fp, line, MAXLINE) != EOF) { ! if (Nrows >= MAXROWS) { ! fprintf (stderr, ! "ERROR: Too many rows in read_data_file. ERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! n = getwords (line, words, MAXCOLS); ! if (Columns < n) ! Columns = n; ! Nrows++; } } ! printf ! ("\nThere are %d rows (cases)\n\tand %d Columns (variables) in the data set\n", ! Nrows, Columns); } /* ! * Return the number of words from fgetline(). ! * Replaced \0 with \t in parts. */ *************** *** 156,244 **** { ! bool is_int, is_float, is_char; ! char *p = line; ! int nwords, testing, location; ! nwords = 0; ! /* Infinite. Break within. */ ! while (1) { ! /* Set to false for first run of word. */ ! is_int = is_float = is_char = false; ! /* If a space, go until not. */ ! while (isspace (*p)) ! p++; ! /* If end of line, go home with results. */ ! if (*p == '\0') ! return nwords; ! location = nwords; ! words[nwords++] = p; ! /* ! * Cycle through until end or separator. ! * Test to determine type of data. ! */ ! while (!isspace (*p) && *p != '\0') { ! testing = isdigit (*p); ! if (is_int == true && *p == '.' && is_float == false) { ! is_float = true; ! is_int = false; } ! else if (is_float == false && is_int == false && is_char == false ! && testing != 0) { ! is_int = true; } ! else if (is_float == false && is_char == false && *p == '.') ! is_float = true; ! else if (testing == 0) { ! is_char = true; ! is_int = false; ! is_float = false; } ! p++; } ! /* Set the Data_Type. */ ! if (is_float == true && Data_Type[location] != CHAR_DATA) { ! Data_Type[location] = FLOAT_DATA; } ! if (is_int == true ! && (Data_Type[location] != CHAR_DATA ! || Data_Type[location] != FLOAT_DATA)) { ! Data_Type[location] = INT_DATA; } ! if (is_char == true) { ! Data_Type[location] = CHAR_DATA; } ! /* If end, go back. */ ! if (*p == '\0') ! return nwords; ! /* Need and error here. */ ! if (nwords >= maxwords) ! return nwords; ! /*We need to go back look at next word. */ ! p++; } --- 157,245 ---- { ! bool is_int, is_float, is_char; ! char *p = line; ! int nwords, testing, location; ! nwords = 0; ! /* Infinite. Break within. */ ! while (1) { ! /* Set to false for first run of word. */ ! is_int = is_float = is_char = false; ! /* If a space, go until not. */ ! while (isspace (*p)) ! p++; ! /* If end of line, go home with results. */ ! if (*p == '\0') ! return nwords; ! location = nwords; ! words[nwords++] = p; ! /* ! * Cycle through until end or separator. ! * Test to determine type of data. ! */ ! while (!isspace (*p) && *p != '\0') { ! testing = isdigit (*p); ! if (is_int == true && *p == '.' && is_float == false) { ! is_float = true; ! is_int = false; } ! else if (is_float == false && is_int == false && is_char == false ! && testing != 0) { ! is_int = true; } ! else if (is_float == false && is_char == false && *p == '.') ! is_float = true; ! else if (testing == 0) { ! is_char = true; ! is_int = false; ! is_float = false; } ! p++; } ! /* Set the Data_Type. */ ! if (is_float == true && Data_Type[location] != CHAR_DATA) { ! Data_Type[location] = FLOAT_DATA; } ! if (is_int == true ! && (Data_Type[location] != CHAR_DATA ! || Data_Type[location] != FLOAT_DATA)) { ! Data_Type[location] = INT_DATA; } ! if (is_char == true) { ! Data_Type[location] = CHAR_DATA; } ! /* If end, go back. */ ! if (*p == '\0') ! return nwords; ! /* Need and error here. */ ! if (nwords >= maxwords) ! return nwords; ! /* We need to go back look at next word. */ ! p++; } *************** *** 247,255 **** /* ! * fgetline() ! * Gets a line of data from a file. ! * Return EOF if end of file or number of characters. ! * Writes values of line to line[] array. ! * max is maximum line length. */ --- 248,255 ---- /* ! * Gets a line of data from a file. ! * Return EOF if end of file or number of characters. ! * Writes values of line to line[] array. ! * max is maximum line length. */ *************** *** 257,289 **** fgetline (FILE * fp, char line[], int max) { ! int nch = 0; ! int c; ! max = max - 1; ! while ((c = getc (fp)) != EOF) { ! if (c == '\n') ! break; ! if (nch < max) { ! line[nch] = c; ! nch = nch + 1; } } ! if (c == EOF && nch == 0) ! return EOF; ! line[nch] = '\0'; ! return nch; } /* ! * Just shows the log file. ! * Very sloppy for the moment. ! * Need to be more interactive (up/down/copy). */ --- 257,289 ---- fgetline (FILE * fp, char line[], int max) { ! int nch = 0; ! int c; ! max = max - 1; ! while ((c = getc (fp)) != EOF) { ! if (c == '\n') ! break; ! if (nch < max) { ! line[nch] = c; ! nch = nch + 1; } } ! if (c == EOF && nch == 0) ! return EOF; ! line[nch] = '\0'; ! return nch; } /* ! * Just shows the log file. ! * Very sloppy for the moment. ! * Need to be more interactive (up/down/copy). */ *************** *** 292,303 **** { ! rewind (Log_File); ! printf ("LOGFILE\n\n"); ! printline (Log_File); } /* ! * Currently print a file. */ --- 292,303 ---- { ! rewind (Log_File); ! printf ("LOGFILE\n\n"); ! printline (Log_File); } /* ! * Currently print a file. */ *************** *** 305,317 **** printline (FILE * fp) { ! char s[MAXLINE]; ! while ((fgets (s, MAXLINE, fp)) != NULL) ! printf ("%s", s); } /* ! * Update the log file. */ --- 305,317 ---- printline (FILE * fp) { ! char s[MAXLINE]; ! while ((fgets (s, MAXLINE, fp)) != NULL) ! printf ("%s", s); } /* ! * Update the log file. */ *************** *** 319,341 **** update_logfile (char *message) { ! if (Log_File_Flag) { ! if ((fprintf (Log_File, "\n\n")) < 0) { ! fprintf (stderr, ! "\n\nERROR: not printing to log file.\nERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! fprintf (Log_File, "%s", message); ! /*Only need for Cygwin */ ! /*Seems to do no harm in Linux */ ! if ((fflush (Log_File)) == EOF) { ! printf ("Unable to flush the logfile!\n"); ! exit (EXIT_FAILURE); } } --- 319,341 ---- update_logfile (char *message) { ! if (Log_File_Flag) { ! if ((fprintf (Log_File, "\n\n")) < 0) { ! fprintf (stderr, ! "\n\nERROR: not printing to log file.\nERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! fprintf (Log_File, "%s", message); ! /* Only need for Cygwin */ ! /* Seems to do no harm in Linux */ ! if ((fflush (Log_File)) == EOF) { ! printf ("Unable to flush the logfile!\n"); ! exit (EXIT_FAILURE); } } *************** *** 343,349 **** /* ! * Use to read only certain Columns. ! * Fills t[]. Element is column of data set. ! * Returns to be worked out */ --- 343,349 ---- /* ! * Use to read only certain Columns. ! * Fills t[]. Element is column of data set. ! * Returns to be worked out */ *************** *** 351,397 **** getit (FILE * file_name, int element, long double t[]) { ! static FILE *temp_fp; /*used for passing between read functions */ ! char line[MAXLINE]; ! char *words[MAXLINE]; ! int n; ! int i; ! temp_fp = file_name; ! i = 0; ! if (file_name == NULL) { ! fprintf (stderr, ! "\n\nDatafile is not open for some reason?\n\nFatal ERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! else { ! rewind (Data_File); ! while (fgetline (temp_fp, line, MAXLINE) != EOF) { ! if (i >= MAXROWS) { ! fprintf (stderr, ! "ERROR: Too many rows (%d, max %d) in getit. ERROR: %s\n\n", ! i, MAXROWS, strerror (errno)); ! exit (EXIT_FAILURE); } ! n = getwords (line, words, MAXCOLS); ! t[i] = atof (words[element]); ! i++; } } ! return 1; } --- 351,399 ---- getit (FILE * file_name, int element, long double t[]) { ! static FILE *temp_fp; /* Used for passing between read functions. */ ! char line[MAXLINE]; ! char *words[MAXLINE]; ! int n; ! int i; ! temp_fp = file_name; ! i = 0; ! if (file_name == NULL) { ! fprintf (stderr, ! "\n\nDatafile is not open for some reason?\n\nFatal ERROR: %s\n\n", ! strerror (errno)); ! exit (EXIT_FAILURE); } ! else { ! rewind (Data_File); ! while (fgetline (temp_fp, line, MAXLINE) != EOF) { ! if (i >= MAXROWS) { ! fprintf (stderr, ! "ERROR: Too many rows (%d, max %d) in getit. ERROR: %s\n\n", ! i, MAXROWS, strerror (errno)); ! exit (EXIT_FAILURE); } ! n = getwords (line, words, MAXCOLS); ! t[i] = atof (words[element]); ! i++; } } ! return 1; } + + /* Here ends file_ops.c. */ Index: error.c =================================================================== RCS file: /cvsroot/mistat/mistat/src/error.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** error.c 29 May 2004 19:59:23 -0000 1.10 --- error.c 9 Jun 2004 17:00:05 -0000 1.11 *************** *** 1,22 **** ! /* Error handling for mistat. ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ - /*error.c*/ #include <stdio.h> --- 1,25 ---- ! /* Error handling for mistat. ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! */ ! /* ! * error.c USAGE: Not sure yet. */ #include <stdio.h> *************** *** 28,33 **** /* ! * Called by main.c. ! * Sets up for error's to go here. */ --- 31,36 ---- /* ! * Called by main.c. ! * Sets up for error's to go here. */ *************** *** 35,57 **** set_signals (void) { ! signal (SIGABRT, signal_abrt); ! signal (SIGFPE, signal_fpe); ! signal (SIGILL, signal_ill); ! signal (SIGINT, signal_int); ! signal (SIGSEGV, signal_segv); ! signal (SIGTERM, signal_term); } ! /*The next six are the error handlers.*/ void signal_abrt (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGABRT: From abort!%d\n", sig_value); ! exit (EXIT_FAILURE); } --- 38,60 ---- set_signals (void) { ! signal (SIGABRT, signal_abrt); ! signal (SIGFPE, signal_fpe); ! signal (SIGILL, signal_ill); ! signal (SIGINT, signal_int); ! signal (SIGSEGV, signal_segv); ! signal (SIGTERM, signal_term); } ! /* The next six are the error handlers. */ void signal_abrt (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGABRT: From abort!%d\n", sig_value); ! exit (EXIT_FAILURE); } *************** *** 59,68 **** signal_fpe (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGFPE: Math error: divide by 0 or overflow! Value: ->%d<-.\n", ! sig_value); ! exit (EXIT_FAILURE); } --- 62,71 ---- signal_fpe (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGFPE: Math error: divide by 0 or overflow! Value: ->%d<-.\n", ! sig_value); ! exit (EXIT_FAILURE); } *************** *** 70,78 **** signal_ill (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGILL: Illegal instruction! %d\n", sig_value); ! exit (EXIT_FAILURE); } --- 73,81 ---- signal_ill (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGILL: Illegal instruction! %d\n", sig_value); ! exit (EXIT_FAILURE); } *************** *** 80,88 **** signal_int (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGINT: Interrupt! A ctrl-c!%d\n", sig_value); ! exit (EXIT_FAILURE); } --- 83,91 ---- signal_int (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGINT: Interrupt! A ctrl-c!%d\n", sig_value); ! exit (EXIT_FAILURE); } *************** *** 90,98 **** signal_segv (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGSEGV: invalid access to storage! Value: ->%d<-.\n", sig_value); ! exit (EXIT_FAILURE); } --- 93,101 ---- signal_segv (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGSEGV: invalid access to storage! Value: ->%d<-.\n", sig_value); ! exit (EXIT_FAILURE); } *************** *** 100,108 **** signal_term (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGTERM: Termination request sent!%d\n", sig_value); ! exit (EXIT_FAILURE); } --- 103,111 ---- signal_term (int sig_value) { ! printf ("\n\n"); ! if (Bell) ! printf ("\a"); ! printf ("SIGTERM: Termination request sent!%d\n", sig_value); ! exit (EXIT_FAILURE); } Index: system.h =================================================================== RCS file: /cvsroot/mistat/mistat/src/system.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** system.h 29 May 2004 19:59:23 -0000 1.6 --- system.h 9 Jun 2004 17:00:05 -0000 1.7 *************** *** 1,56 **** ! /* Shared definitions for mistat. ! ! Copyright (C) 2003, 2004 Mike H. Benton ! Mike H. Benton <bik...@us...>, 2003. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ - /*system.h*/ - /*USAGE: bool, flags, and MLINE.*/ #ifndef SYSTEM_H ! #define SYSTEM_H ! /*If using autoconf.*/ ! #ifdef HAVE_CONFIG_H ! #include "config.h" ! #endif ! /*Bring in bool.*/ ! #if HAVE_STDBOOL_H ! # include <stdbool.h> ! #else ! # define bool _Bool ! # define false 0 ! # define true 1 ! # define __bool_true_false_are_defined 1 ! #endif ! #include "memwatch.h" /* ! * Defines */ ! #define MLINE 255 /*Maximum input line length */ /* ! * Variables */ ! bool Bell; /*Determine to see if sound system bell */ bool Log_File_Flag; extern bool Data_File_Exist; #endif ! /*Here ends system.h.*/ --- 1,59 ---- ! /* Shared definitions for mistat. ! ** ! ** Copyright (C) 2003, 2004 Mike H. Benton ! ** Mike H. Benton <bik...@us...>, 2003. ! ** ! ** This program is free software; you can redistribute it and/or modify ! ** it under the terms of the GNU General Public License as published by ! ** the Free Software Foundation; either version 2 of the License, or ! ** (at your option) any later version. ! ** ! ** This program is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with this program; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ! */ ! ! /* ! * system.h USAGE: bool, flags, and MLINE. */ #ifndef SYSTEM_H ! # define SYSTEM_H ! /* If using autoconf. */ ! # ifdef HAVE_CONFIG_H ! # include "config.h" ! # endif ! /* Bring in bool. */ ! # if HAVE_STDBOOL_H ! # include <stdbool.h> ! # else ! # define bool _Bool ! # define false 0 ! # define true 1 ! # define __bool_true_false_are_defined 1 ! # endif ! # include "memwatch.h" /* ! * Defines */ ! # define MLINE 255 /* Maximum input line length. */ /* ! * Variables */ ! bool Bell; /* Determine to see if sound system bell. */ bool Log_File_Flag; + bool bTest; /* Test mode enabled. */ extern bool Data_File_Exist; #endif ! /* Here ends system.h. */ Index: cmdline.c =================================================================== RCS file: /cvsroot/mistat/mistat/src/cmdline.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cmdline.c 29 May 2004 18:22:23 -0000 1.8 --- cmdline.c 9 Jun 2004 17:00:05 -0000 1.9 *************** *** 6,15 **** The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: ! we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H ! #include "config.h" #endif --- 6,15 ---- The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: ! we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H ! # include "config.h" #endif *************** *** 25,33 **** static void clear_args (struct gengetopt_args_info *args_info); ! static int ! cmdline_parser_internal (int argc, char *const *argv, ! struct gengetopt_args_info *args_info, int override, ! int initialize, int check_required, ! const char *additional_error); static char *gengetopt_strdup (const char *s); --- 25,33 ---- static void clear_args (struct gengetopt_args_info *args_info); ! static int cmdline_parser_internal (int argc, char *const *argv, ! struct gengetopt_args_info *args_info, ! int override, int initialize, ! int check_required, ! const char *additional_error); static char *gengetopt_strdup (const char *s); *************** *** 36,45 **** clear_given (struct gengetopt_args_info *args_info) { ! args_info->help_given = 0; ! args_info->version_given = 0; ! args_info->nobell_given = 0; ! args_info->digits_given = 0; ! args_info->log_given = 0; ! args_info->nofile_given = 0; } --- 36,46 ---- clear_given (struct gengetopt_args_info *args_info) { ! args_info->help_given = 0; ! args_info->version_given = 0; ! args_info->nobell_given = 0; ! args_info->digits_given = 0; ! args_info->log_given = 0; ! args_info->nofile_given = 0; ! args_info->test_given = 0; } *************** *** 47,54 **** clear_args (struct gengetopt_args_info *args_info) { ! args_info->nobell_flag = 0; ! args_info->digits_arg = 2; ! args_info->log_flag = 0; ! args_info->nofile_flag = 0; } --- 48,56 ---- clear_args (struct gengetopt_args_info *args_info) { ! args_info->nobell_flag = 0; ! args_info->digits_arg = 2; ! args_info->log_flag = 0; ! args_info->nofile_flag = 0; ! args_info->test_flag = 0; } *************** *** 56,60 **** cmdline_parser_print_version (void) { ! printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } --- 58,62 ---- cmdline_parser_print_version (void) { ! printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } *************** *** 62,81 **** cmdline_parser_print_help (void) { ! cmdline_parser_print_version (); ! printf ("\n" ! "Purpose:\n" ! " mistat is a statistical program based on statist.\nCopyright (C) 2003 Mike H. Benton\nmistat comes with NO WARRANTY, \nto the extent permitted by law. \nYou may redistribute copies of mistat\nunder the terms of the GNU General Public License. \nFor more information about these matters, \nsee the files named COPYING. \n\n" ! "\n" "Usage: %s [OPTIONS]... [FILES]...\n", CMDLINE_PARSER_PACKAGE); ! printf ("\n"); ! printf ("%s\n", " -h, --help Print help and exit"); ! printf ("%s\n", " -V, --version Print version and exit"); ! printf ("%s\n", ! " -b, --nobell No beeps on errors or warnings (default=off)"); ! printf ("%s\n", ! " -d, --digits=INT Number of digits to print (default=`2')"); ! printf ("%s\n", ! " -l, --log Write results to statist.log (default=off)"); ! printf ("%s\n", ! " -n, --nofile Do not read data file on startup.\n\t\t\tData file must be specified from menu. (default=off)\n"); } --- 64,84 ---- cmdline_parser_print_help (void) { ! cmdline_parser_print_version (); ! printf ("\n" "Purpose:\n" ! " mistat is a statistical program based on statist.\nCopyright (C) 2004 Mike H. Benton\nmistat comes with NO WARRANTY, \nto the extent permitted by law. \nYou may redistribute copies of mistat\nunder the terms of the GNU General Public License. \nFor more information about these matters, \nsee the files named COPYING. \n\n" ! "\n" "Usage: %s [OPTIONS]... [FILES]...\n", CMDLINE_PARSER_PACKAGE); ! printf ("\n"); ! printf ("%s\n", " -h, --help Print help and exit"); ! printf ("%s\n", " -V, --version Print version and exit"); ! printf ("%s\n", ! " -b, --nobell No beeps on errors or warnings (default=off)"); ! printf ("%s\n", ! " -d, --digits=INT Number of digits to print (default=`2')"); ! printf ("%s\n", ! " -l, --log Write results to statist.log (default=off)"); ! printf ("%s\n", ! " -n, --nofile Do not read data file on startup.\n\t\t\tData file must be specified from menu. (default=off)\n"); ! printf ("%s\n", ! " -t, --test Suppy testing options.\n \t\tIncrease number of sig. digits. (default=off)"); } *************** *** 83,91 **** cmdline_parser_init (struct gengetopt_args_info *args_info) { ! clear_given (args_info); ! clear_args (args_info); ! args_info->inputs = NULL; ! args_info->inputs_num = 0; } --- 86,94 ---- cmdline_parser_init (struct gengetopt_args_info *args_info) { ! clear_given (args_info); ! clear_args (args_info); ! args_info->inputs = NULL; ! args_info->inputs_num = 0; } *************** *** 94,106 **** { ! unsigned i; ! for (i = 0; i < args_info->inputs_num; ++i) ! free (args_info->inputs[i]); ! if (args_info->inputs_num) ! free (args_info->inputs); ! clear_given (args_info); } --- 97,109 ---- { ! unsigned i; ! for (i = 0; i < args_info->inputs_num; ++i) ! free (args_info->inputs[i]); ! if (args_info->inputs_num) ! free (args_info->inputs); ! clear_given (args_info); } *************** *** 111,123 **** gengetopt_strdup (const char *s) { ! char *result = NULL; ! if (!s) ! return result; ! result = (char *) malloc (strlen (s) + 1); ! if (result == (char *) 0) ! return (char *) 0; ! strcpy (result, s); ! return result; } --- 114,126 ---- gengetopt_strdup (const char *s) { ! char *result = NULL; ! if (!s) ! return result; ! result = (char *) malloc (strlen (s) + 1); ! if (result == (char *) 0) ! return (char *) 0; ! strcpy (result, s); ! return result; } *************** *** 126,130 **** struct gengetopt_args_info *args_info) { ! return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } --- 129,133 ---- struct gengetopt_args_info *args_info) { ! return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } *************** *** 134,150 **** int initialize, int check_required) { ! int result; ! result = ! cmdline_parser_internal (argc, argv, args_info, override, initialize, ! check_required, NULL); ! if (result == EXIT_FAILURE) { ! cmdline_parser_free (args_info); ! exit (EXIT_FAILURE); } ! return result; } --- 137,153 ---- int initialize, int check_required) { ! int result; ! result = ! cmdline_parser_internal (argc, argv, args_info, override, initialize, ! check_required, NULL); ! if (result == EXIT_FAILURE) { ! cmdline_parser_free (args_info); ! exit (EXIT_FAILURE); } ! return result; } *************** *** 155,181 **** const char *additional_error) { ! int c; /* Character of the parsed option. */ ! int error = 0; ! struct gengetopt_args_info local_args_info; ! if (initialize) ! cmdline_parser_init (args_info); ! cmdline_parser_init (&local_args_info); ! optarg = 0; ! optind = 1; ! opterr = 1; ! optopt = '?'; ! while (1) { ! int option_index = 0; ! char *stop_char; ! static struct option long_options[] = ! { ! {"help", 0, NULL, 'h' ! }, {"version", 0, NULL, 'V'}, {"nobell", 0, NULL, 'b'}, --- 158,182 ---- const char *additional_error) { ! int c; /* Character of the parsed option. */ ! int error = 0; ! struct gengetopt_args_info local_args_info; ! if (initialize) ! cmdline_parser_init (args_info); ! cmdline_parser_init (&local_args_info); ! optarg = 0; ! optind = 1; ! opterr = 1; ! optopt = '?'; ! while (1) { ! int option_index = 0; ! char *stop_char; ! static struct option long_options[] = { ! {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'V'}, {"nobell", 0, NULL, 'b'}, *************** *** 183,317 **** {"log", 0, NULL, 'l'}, {"nofile", 0, NULL, 'n'}, {NULL, 0, NULL, 0} ! }; ! stop_char = 0; ! c = getopt_long (argc, argv, "hVbd:ln", long_options, &option_index); ! if (c == -1) ! break; /* Exit from `while (1)' loop. */ ! switch (c) { ! case 'h': /* Print help and exit. */ ! cmdline_parser_print_help (); ! exit (EXIT_SUCCESS); ! case 'V': /* Print version and exit. */ ! cmdline_parser_print_version (); ! exit (EXIT_SUCCESS); ! case 'b': /* No beeps on errors or warnings. */ ! if (local_args_info.nobell_given) { ! fprintf (stderr, ! "%s: `--nobell' (`-b') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->nobell_given && !override) ! continue; ! local_args_info.nobell_given = 1; ! args_info->nobell_given = 1; ! args_info->nobell_flag = !(args_info->nobell_flag); ! break; ! case 'd': /* Number of digits to print. */ ! if (local_args_info.digits_given) { ! fprintf (stderr, ! "%s: `--digits' (`-d') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->digits_given && !override) ! continue; ! local_args_info.digits_given = 1; ! args_info->digits_given = 1; ! args_info->digits_arg = strtol (optarg, &stop_char, 0); ! break; ! case 'l': /* Write results to statist.log. */ ! if (local_args_info.log_given) { ! fprintf (stderr, ! "%s: `--log' (`-l') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->log_given && !override) ! continue; ! local_args_info.log_given = 1; ! args_info->log_given = 1; ! args_info->log_flag = !(args_info->log_flag); ! break; ! case 'n': /* Do not read data file on startup.\n\t\t\tData file must be specified from menu.. */ ! if (local_args_info.nofile_given) { ! fprintf (stderr, ! "%s: `--nofile' (`-n') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->nofile_given && !override) ! continue; ! local_args_info.nofile_given = 1; ! args_info->nofile_given = 1; ! args_info->nofile_flag = !(args_info->nofile_flag); ! break; - case 0: /* Long option with no short option */ ! case '?': /* Invalid option. */ ! /* `getopt_long' already printed an error message. */ ! goto failure; ! default: /* bug: option not considered. */ ! fprintf (stderr, "%s: option unknown: %c%s\n", ! CMDLINE_PARSER_PACKAGE, c, ! (additional_error ? additional_error : "")); ! abort (); ! } /* switch */ ! } /* while */ ! if (check_required) ! {} ! if (error) ! return (EXIT_FAILURE); ! if (optind < argc) { ! if ((argc - optind) == 1) { ! int i = 0; ! args_info->inputs_num = argc - optind; ! args_info->inputs = ! (char **) (malloc ((args_info->inputs_num) * sizeof (char *))); ! while (optind < argc) ! args_info->inputs[i++] = gengetopt_strdup (argv[optind++]); } ! else { ! printf ("Only one file can be used for input! Exiting.\n\n"); ! exit (EXIT_FAILURE); } } ! return 0; ! failure: ! cmdline_parser_free (&local_args_info); ! return (EXIT_FAILURE); } --- 184,336 ---- {"log", 0, NULL, 'l'}, {"nofile", 0, NULL, 'n'}, + {"test", 0, NULL, 't'}, {NULL, 0, NULL, 0} ! }; ! stop_char = 0; ! c = getopt_long (argc, argv, "hVbd:lnt", long_options, &option_index); ! if (c == -1) ! break; /* Exit from `while (1)' loop. */ ! switch (c) { ! case 'h': /* Print help and exit. */ ! cmdline_parser_print_help (); ! exit (EXIT_SUCCESS); ! case 'V': /* Print version and exit. */ ! cmdline_parser_print_version (); ! exit (EXIT_SUCCESS); ! case 'b': /* No beeps on errors or warnings. */ ! if (local_args_info.nobell_given) { ! fprintf (stderr, ! "%s: `--nobell' (`-b') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->nobell_given && !override) ! continue; ! local_args_info.nobell_given = 1; ! args_info->nobell_given = 1; ! args_info->nobell_flag = !(args_info->nobell_flag); ! break; ! case 'd': /* Number of digits to print. */ ! if (local_args_info.digits_given) { ! fprintf (stderr, ! "%s: `--digits' (`-d') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->digits_given && !override) ! continue; ! local_args_info.digits_given = 1; ! args_info->digits_given = 1; ! args_info->digits_arg = strtol (optarg, &stop_char, 0); ! break; ! case 'l': /* Write results to statist.log. */ ! if (local_args_info.log_given) { ! fprintf (stderr, ! "%s: `--log' (`-l') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->log_given && !override) ! continue; ! local_args_info.log_given = 1; ! args_info->log_given = 1; ! args_info->log_flag = !(args_info->log_flag); ! break; ! case 'n': /* Do not read data file on startup.\n\t\t\tData file must be specified from menu.. */ ! if (local_args_info.nofile_given) { ! fprintf (stderr, ! "%s: `--nofile' (`-n') option given more than once%s\n", ! CMDLINE_PARSER_PACKAGE, ! (additional_error ? additional_error : "")); ! goto failure; } ! if (args_info->nofile_given && !override) ! continue; ! local_args_info.nofile_given = 1; ! args_info->nofile_given = 1; ! args_info->nofile_flag = !(args_info->nofile_flag); ! break; + case 't': /* Suppy testing options.\n\t\tIncrease number of sig. digits.. */ + if (local_args_info.test_given) + { + fprintf (stderr, + "%s: `--test' (`-t') option given more than once%s\n", + CMDLINE_PARSER_PACKAGE, + (additional_error ? additional_error : "")); + goto failure; + } + if (args_info->test_given && !override) + continue; + local_args_info.test_given = 1; + args_info->test_given = 1; + args_info->test_flag = !(args_info->test_flag); + break; ! case 0: /* Long option with no short option */ ! case '?': /* Invalid option. */ ! /* `getopt_long' already printed an error message. */ ! goto failu... [truncated message content] |