summaryrefslogtreecommitdiff
path: root/ldmicro/loadsave.cpp
diff options
context:
space:
mode:
authorakshay-c2019-04-09 10:46:06 +0530
committerakshay-c2019-04-09 10:46:06 +0530
commitdf1231112f08a66addd444c08839dee87905974d (patch)
treeba9409f32310c1a2163943e58057e59f15e89474 /ldmicro/loadsave.cpp
parent04220d0ad3d86a996f6163ed16a86d1a71574132 (diff)
downloadLDmicroQt-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.cpp14
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;