diff options
author | akshay-c | 2019-04-09 10:46:06 +0530 |
---|---|---|
committer | akshay-c | 2019-04-09 10:46:06 +0530 |
commit | df1231112f08a66addd444c08839dee87905974d (patch) | |
tree | ba9409f32310c1a2163943e58057e59f15e89474 /ldmicro/loadsave.cpp | |
parent | 04220d0ad3d86a996f6163ed16a86d1a71574132 (diff) | |
download | LDmicroQt-df1231112f08a66addd444c08839dee87905974d.tar.gz LDmicroQt-df1231112f08a66addd444c08839dee87905974d.tar.bz2 LDmicroQt-df1231112f08a66addd444c08839dee87905974d.zip |
Drawing Elements and HelpDialog
Diffstat (limited to 'ldmicro/loadsave.cpp')
-rw-r--r-- | ldmicro/loadsave.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ldmicro/loadsave.cpp b/ldmicro/loadsave.cpp index a1895a5..b07ec4b 100644 --- a/ldmicro/loadsave.cpp +++ b/ldmicro/loadsave.cpp @@ -235,6 +235,7 @@ static ElemSubcktParallel *LoadParallelFromFile(FILE *f) for(;;) { if(!fgets(line, sizeof(line), f)) return NULL; + ManageLineEnding(line); char *s = line; while(isspace(*s)) s++; @@ -275,6 +276,7 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f) for(;;) { if(!fgets(line, sizeof(line), f)) return NULL; + ManageLineEnding(line); char *s = line; @@ -305,6 +307,16 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f) } } +void ManageLineEnding(char* line) +{ + int charlen = strlen(line) - 2; + if(line[charlen] == '\r') + { + line[charlen++] = '\n'; + line[charlen] = '\0'; + } +} + //----------------------------------------------------------------------------- // Load a project from a saved project description files. This describes the // program, the target processor, plus certain configuration settings (cycle @@ -323,6 +335,7 @@ BOOL LoadProjectFromFile(char *filename) int crystal, cycle, baud; while(fgets(line, sizeof(line), f)) { + ManageLineEnding(line); if(strcmp(line, "IO LIST\n")==0) { if(!LoadIoListFromFile(f)) { fclose(f); @@ -359,6 +372,7 @@ BOOL LoadProjectFromFile(char *filename) int rung; for(rung = 0;;) { if(!fgets(line, sizeof(line), f)) break; + ManageLineEnding(line); if(strcmp(line, "RUNG\n")!=0) goto failed; |