This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Ellipsis use with C51 for 8051


I have some legacy code that was originally compiled with Franklin and it also compiles with my Keil compiler. The problem is that the source code does some things that make no sense and I cannot find any documentation in my Keil manuals or on the website about this topic. I want to ensure that 1) the code still operates the same using Keil vs Franklin compiler 2) I understand how it works. The manuals reference va_start,va_end macros. Can the code below be written to use those macros? How? If so, would this be a better option? Looking at the ouput src file, it appears that keil makes a undocumented library call.

I look forward to your inputs.

Thanks,

Paul Calvert
256-704-4134

Here is the code snipet:

int sscanf(char *inBfrPtr, char *fmtPtr, ...)
{
Byte scanResult = 0;
void *argPtr = &ellipsis_40; //THIS IS THE STATEMENT THAT I CAN FIND NO REFERNCE TO: ELLIPSIS_40. THERE ARE NO MACROS OR OTHER DECLARATIONS ANYWHERE IN MY CODE REFERENCING "ELLIPSIS_"
register char tmpDigit;

while(1){
if(*fmtPtr == '\0')
break;
else if(*fmtPtr == '%'){
fmtPtr++;
if(*fmtPtr == 'c'){
**(char **)argPtr = *inBfrPtr;
argPtr += 3;
fmtPtr++;
inBfrPtr++;
scanResult += 1;
continue;
}
else if(*fmtPtr == 'd'){
if(inBfrPtr[0] == '+' || inBfrPtr[0] == '-')
tmpDigit = inBfrPtr[1];
else
tmpDigit = inBfrPtr[0];
if(tmpDigit >= '0' && tmpDigit <= '9'){
**(int **)argPtr = atoi(inBfrPtr);
while(1){
inBfrPtr++;
if(inBfrPtr[0] < '0' || inBfrPtr[0] > '9')
break;
}
fmtPtr++;
argPtr += 3;
scanResult += 1;
continue;
}
else
break;
}
else if(*fmtPtr == '%'){
/* fall through to continue string comparison */
}
else{ /* unknown format specifier */
break;
}
}
if(*fmtPtr++ != *inBfrPtr++)
break;
}
return(scanResult);
}

0