summaryrefslogtreecommitdiff
path: root/ldmicro/ldinterpret.c
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/ldinterpret.c
parent04220d0ad3d86a996f6163ed16a86d1a71574132 (diff)
downloadLDmicroQt-df1231112f08a66addd444c08839dee87905974d.tar.gz
LDmicroQt-df1231112f08a66addd444c08839dee87905974d.tar.bz2
LDmicroQt-df1231112f08a66addd444c08839dee87905974d.zip
Drawing Elements and HelpDialog
Diffstat (limited to 'ldmicro/ldinterpret.c')
-rw-r--r--ldmicro/ldinterpret.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ldmicro/ldinterpret.c b/ldmicro/ldinterpret.c
index a37ff09..da7a50e 100644
--- a/ldmicro/ldinterpret.c
+++ b/ldmicro/ldinterpret.c
@@ -107,6 +107,17 @@ int HexDigit(int c)
}
return 0;
}
+
+void ManageLineEnding(char* line)
+{
+ int charlen = strlen(line) - 2;
+ if(line[charlen] == '\r')
+ {
+ line[charlen++] = '\n';
+ line[charlen] = '\0';
+ }
+}
+
void LoadProgram(char *fileName)
{
int pc;
@@ -121,6 +132,7 @@ void LoadProgram(char *fileName)
}
if(!fgets(line, sizeof(line), f)) BadFormat();
+ ManageLineEnding(line);
if(strcmp(line, "$$LDcode\n")!=0) BadFormat();
for(pc = 0; ; pc++) {
@@ -128,6 +140,7 @@ void LoadProgram(char *fileName)
BYTE *b;
if(!fgets(line, sizeof(line), f)) BadFormat();
+ ManageLineEnding(line);
if(strcmp(line, "$$bits\n")==0) break;
if(strlen(line) != sizeof(BinOp)*2 + 1) BadFormat();
@@ -143,6 +156,7 @@ void LoadProgram(char *fileName)
SpecialAddrForA = -1;
SpecialAddrForXosc = -1;
while(fgets(line, sizeof(line), f)) {
+ ManageLineEnding(line);
if(memcmp(line, "a,", 2)==0) {
SpecialAddrForA = atoi(line+2);
}