Tree @457be729-5368-47f5-83d0-c4fdf3c09209/main (Download .tar.gz)
- ..
- cocoa
- helpers
- libbz2
- liblzma
- libz
- ae2.c
- ae2.h
- analyzer.c
- analyzer.h
- baseconvert.c
- baseconvert.h
- bitvec.c
- bsearch.c
- bsearch.h
- busy.c
- busy.h
- clipping.c
- clipping.h
- color.c
- color.h
- com.geda.gtkwave.gschema.xml
- currenttime.c
- currenttime.h
- debug.c
- debug.h
- discardbuttons.c
- edgebuttons.c
- edgebuttons.h
- entry.c
- entry.h
- extload.c
- extload.h
- fetchbuttons.c
- fetchbuttons.h
- fgetdynamic.c
- fgetdynamic.h
- file.c
- file.h
- fonts.c
- fonts.h
- fsdb_wrapper_api.cc
- fsdb_wrapper_api.h
- fst.c
- fst.h
- gconf.c
- gconf.h
- getopt.c
- getopt1.c
- ghw.c
- ghw.h
- globals.c
- globals.h
- gnu-getopt.h
- gnu_regex.c
- gnu_regex.h
- gtk12compat.h
- help.c
- help.h
- hierpack.c
- hierpack.h
- hiersearch.c
- hiersearch.h
- interp.c
- interp.h
- jrb.c
- jrb.h
- libghw.c
- libghw.h
- logfile.c
- logfile.h
- lx2.c
- lx2.h
- lxt.c
- lxt.h
- main.c
- main.h
- Makefile.am
- Makefile.in
- markerbox.c
- markerbox.h
- menu.c
- menu.h
- mouseover.c
- mouseover.h
- mouseover_sigs.c
- mouseover_sigs.h
- pagebuttons.c
- pagebuttons.h
- pipeio.c
- pipeio.h
- pixmaps.c
- pixmaps.h
- print.c
- print.h
- ptranslate.c
- ptranslate.h
- rc.c
- rc.h
- regex.c
- regex_wave.h
- renderopt.c
- renderopt.h
- rgb.c
- savefile.c
- savefile.h
- search.c
- search.h
- shiftbuttons.c
- shiftbuttons.h
- showchange.c
- showchange.h
- signalwindow.c
- signalwindow.h
- simplereq.c
- simplereq.h
- splash.c
- status.c
- status.h
- strace.c
- strace.h
- symbol.c
- symbol.h
- tcl_callbacks.h
- tcl_commands.c
- tcl_helper.c
- tcl_helper.h
- tcl_np.c
- tcl_np.h
- tcl_support_commands.c
- tcl_support_commands.h
- timeentry.c
- timeentry.h
- translate.c
- translate.h
- tree.c
- tree.h
- tree_component.c
- tree_component.h
- treesearch.c
- treesearch.h
- treesearch_gtk1.c
- treesearch_gtk2.c
- ttranslate.c
- ttranslate.h
- twinwave.c
- vcd.c
- vcd.h
- vcd_keywords.c
- vcd_keywords.gperf
- vcd_partial.c
- vcd_partial.h
- vcd_recoder.c
- vcd_saver.c
- vcd_saver.h
- version.h
- vlist.c
- vlist.h
- vzt.c
- vzt.h
- wavealloca.h
- wavewindow.c
- wavewindow.h
- zoombuttons.c
- zoombuttons.h
fgetdynamic.c @457be729-5368-47f5-83d0-c4fdf3c09209/main — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | /* * Copyright (c) Tony Bybell 1999-2013. * * 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. */ #include "globals.h" #include <config.h> #include <string.h> #include <ctype.h> #include "fgetdynamic.h" #include "debug.h" char *fgetmalloc(FILE *handle) { struct vlist_t *v; char *pnt = NULL; int i, ch; v = vlist_create(sizeof(char)); do { for(;;) { ch=fgetc(handle); if((ch==EOF)||(ch==0x00)||(ch=='\n')||(ch=='\r')) break; pnt = (char *)vlist_alloc(&v, 0); *pnt = (char)ch; } } while(!pnt && ((ch=='\n')||(ch=='\r'))); /* fix for \n\r on \n systems */ GLOBALS->fgetmalloc_len = vlist_size(v); if(!GLOBALS->fgetmalloc_len) { pnt = NULL; } else { pnt=malloc_2(GLOBALS->fgetmalloc_len+1); for(i=0;i<GLOBALS->fgetmalloc_len;i++) { pnt[i] = *((char *)vlist_locate(v, i)); } pnt[i] = 0; } vlist_destroy(v); return(pnt); } /* * remove any leading and trailing spaces */ static char *stripspaces(char *s) { int len; if(s) { char *s2 = s + strlen(s) - 1; while(isspace((int)(unsigned char)*s2) && (s2 != s)) { *s2 = 0; s2--; } s2 = s; while(*s2 && isspace((int)(unsigned char)*s2)) { s2++; } if((len = strlen(s2))) { char *s3 = malloc_2(len + 1); strcpy(s3, s2); free_2(s); s = s3; GLOBALS->fgetmalloc_len = len; } else { free_2(s); s = NULL; GLOBALS->fgetmalloc_len = 0; } } return(s); } char *fgetmalloc_stripspaces(FILE *handle) { char *s = fgetmalloc(handle); return(stripspaces(s)); } /* * variants for tcl argument passing which really aren't fgetdynamic-ish functions... * the struct wave_script_args * passed in was generated in tcl_helper.c. */ char *wave_script_args_fgetmalloc(struct wave_script_args *w) { char *pnt; if((!w)||(!w->curr)) return(NULL); pnt = malloc_2(strlen(w->curr->payload)+1); strcpy(pnt, w->curr->payload); w->curr = w->curr->next; return(pnt); } char *wave_script_args_fgetmalloc_stripspaces(struct wave_script_args *w) { char *s = wave_script_args_fgetmalloc(w); return(stripspaces(s)); } |