fix some bugs
This commit is contained in:
parent
439d21a2b4
commit
622ee76980
|
@ -143,7 +143,7 @@ Resource *LookupResource(char *Tag, char *Line)
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessAnnotation(Resource* Resources, size_t ResCount, char *Line, FILE *OutFile)
|
void ProcessAnnotation(char *Line, FILE *OutFile)
|
||||||
{
|
{
|
||||||
SkipWhitespace(&Line);
|
SkipWhitespace(&Line);
|
||||||
assert(*Line == '"');
|
assert(*Line == '"');
|
||||||
|
@ -188,10 +188,11 @@ void ProcessAnnotation(Resource* Resources, size_t ResCount, char *Line, FILE *O
|
||||||
|
|
||||||
for(LinePtr = Line; *LinePtr; ++LinePtr)
|
for(LinePtr = Line; *LinePtr; ++LinePtr)
|
||||||
{
|
{
|
||||||
int ScanBytes;
|
int ScanBytes = 0;
|
||||||
|
int TmpQuoteID;
|
||||||
|
|
||||||
// convert Resource -> ref
|
// convert Resource -> ref
|
||||||
if(LinePtr[0] == ' ' && LinePtr[1] == '[' && sscanf(LinePtr+1, "[see Resources, %255[^]]]%n", RefBuf, &ScanBytes) == 1)
|
if(LinePtr[0] == ' ' && LinePtr[1] == '[' && sscanf(LinePtr+1, "[see Resources, %255[^]]]%n", RefBuf, &ScanBytes) == 1 && ScanBytes)
|
||||||
{
|
{
|
||||||
//printf("Find Resource [%s]\n", RefBuf);
|
//printf("Find Resource [%s]\n", RefBuf);
|
||||||
Resource *Res = LookupResource(RefBuf, Line);
|
Resource *Res = LookupResource(RefBuf, Line);
|
||||||
|
@ -215,14 +216,14 @@ void ProcessAnnotation(Resource* Resources, size_t ResCount, char *Line, FILE *O
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert quotes
|
// convert quotes
|
||||||
else if(LinePtr[0] == ' ' && LinePtr[1] == '(' && sscanf(LinePtr+1, "(!quote %d)%n", &QuoteID, &ScanBytes) == 1)
|
else if(LinePtr[0] == ' ' && LinePtr[1] == '(' && sscanf(LinePtr+1, "(!quote %d)%n", &TmpQuoteID, &ScanBytes) == 1 && ScanBytes)
|
||||||
{
|
{
|
||||||
|
QuoteID = TmpQuoteID;
|
||||||
fprintf(OutFile, "%.*s", (int)(LinePtr - RunStart), RunStart);
|
fprintf(OutFile, "%.*s", (int)(LinePtr - RunStart), RunStart);
|
||||||
LinePtr += ScanBytes;
|
LinePtr += ScanBytes;
|
||||||
RunStart = LinePtr+1;
|
RunStart = LinePtr+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Used for getting name for Q:'s
|
// Used for getting name for Q:'s
|
||||||
else if(*LinePtr == ' ')
|
else if(*LinePtr == ' ')
|
||||||
{
|
{
|
||||||
|
@ -388,7 +389,7 @@ int ProcessFile(char *InFileName, FILE *InFile, FILE *OutFile)
|
||||||
if(strncmp(LinePtr, "---", 3) == 0){
|
if(strncmp(LinePtr, "---", 3) == 0){
|
||||||
goto Done;
|
goto Done;
|
||||||
} else {
|
} else {
|
||||||
ProcessAnnotation(Resources, ResCount, LinePtr, OutFile);
|
ProcessAnnotation(LinePtr, OutFile);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -467,7 +468,7 @@ OpenOutput:;
|
||||||
OutFile = fdopen(OutFileDesc, "w");
|
OutFile = fdopen(OutFileDesc, "w");
|
||||||
if(!OutFile)
|
if(!OutFile)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error opening %s: %s\n", Args[i], strerror(errno));
|
fprintf(stderr, "Error opening %s: %s\n", OutNameBuf, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue