source: issm/oecreview/Archive/11401-11425/ISSM-11405-11406.diff@ 14312

Last change on this file since 14312 was 11515, checked in by Eric.Larour, 13 years ago

Oecreview up to 11509

File size: 2.7 KB
  • proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/KML/KML_Unknown.cpp

     
    6767/*FUNCTION KML_Unknown::DeepEcho {{{1*/
    6868void  KML_Unknown::DeepEcho(const char* indent){
    6969
    70         bool  flag=true;
     70        char*        valuei;
     71        char*        vtoken;
     72        char         nl[]={'\n','\0'};
     73        bool         flag=true;
    7174
    7275        _printf_(flag,"%sKML_Unknown %s:\n",indent,name);
    7376        KML_Object::DeepEcho(indent);
    7477
    75         if (value     )
    76                 _printf_(flag,"%s         value: \"%s\"\n"     ,indent,value);
     78        if (value     ) {
     79                valuei=(char *) xmalloc((strlen(value)+1)*sizeof(char));
     80                memcpy(valuei,value,(strlen(value)+1)*sizeof(char));
     81       
     82                vtoken=strtok(valuei,nl);
     83                _printf_(flag,"%s         value: \"%s"     ,indent,vtoken);
     84   
     85                while (vtoken=strtok(NULL,nl))
     86                        _printf_(flag,"\n%s                 %s"     ,indent,vtoken);
     87                _printf_(flag,"\"\n");
     88
     89                xfree((void**)&valuei);
     90        }
    7791    else
    7892        _printf_(flag,"%s         value: [none]\n"     ,indent);
    7993
     
    8397/*FUNCTION KML_Unknown::Write {{{1*/
    8498void  KML_Unknown::Write(FILE* filout,const char* indent){
    8599
     100        char*        valuei;
     101        char*        vtoken;
     102        char         nl[]={'\n','\0'};
     103
    86104        fprintf(filout,"%s<%s",indent,name);
    87105        WriteAttrib(filout," ");
    88106        fprintf(filout,">\n");
    89107        WriteCommnt(filout,indent);
    90108
    91         if (value     )
    92                 fprintf(filout,"%s  %s\n",indent,value);
     109        if (value     ) {
     110                valuei=(char *) xmalloc((strlen(value)+1)*sizeof(char));
     111                memcpy(valuei,value,(strlen(value)+1)*sizeof(char));
     112       
     113                vtoken=strtok(valuei,nl);
     114                fprintf(filout,"%s  %s\n",indent,vtoken);
     115   
     116                while (vtoken=strtok(NULL,nl))
     117                        fprintf(filout,"%s  %s\n",indent,vtoken);
    93118
     119                xfree((void**)&valuei);
     120        }
     121
    94122        KML_Object::Write(filout,indent);
    95123
    96124        fprintf(filout,"%s</%s>\n",indent,name);
     
    104132        char*        kstri;
    105133        int          ncom=0;
    106134        char**       pcom=NULL;
     135        char         nl[]={'\n','\0'};
    107136
    108137/*  get object name  */
    109138
     
    132161                        _error_("KML_Unknown::Read -- Unexpected closing tag %s.\n",kstri);
    133162
    134163                else if (strncmp(kstri,"<",1)) {
    135                         value=(char *) xmalloc((strlen(kstri)+1)*sizeof(char));
    136                         memcpy(value,kstri,(strlen(kstri)+1)*sizeof(char));
     164                        if (value) {
     165                                value=(char *) xrealloc(value,(strlen(value)+1+strlen(kstri)+1)*sizeof(char));
     166                                strcat(value,nl);
     167                                strcat(value,kstri);
     168                        }
     169                        else {
     170                                value=(char *) xmalloc((strlen(kstri)+1)*sizeof(char));
     171                                memcpy(value,kstri,(strlen(kstri)+1)*sizeof(char));
     172                        }
    137173                }
    138174
    139175                else if (!strncmp(kstri,"<",1))
Note: See TracBrowser for help on using the repository browser.