diff options
Diffstat (limited to 'backends/PalmOS/Src/missing')
-rw-r--r-- | backends/PalmOS/Src/missing/_stdio.cpp | 64 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_stdlib.cpp | 14 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_string.cpp | 10 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_time.cpp | 8 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_unistd.cpp | 2 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/memory.h | 2 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/stdio.h | 4 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/unistd.h | 2 |
8 files changed, 53 insertions, 53 deletions
diff --git a/backends/PalmOS/Src/missing/_stdio.cpp b/backends/PalmOS/Src/missing/_stdio.cpp index f2ee63ac51..cd0e03a878 100644 --- a/backends/PalmOS/Src/missing/_stdio.cpp +++ b/backends/PalmOS/Src/missing/_stdio.cpp @@ -31,12 +31,12 @@ static void dummy(Boolean){}; void StdioInit(UInt16 volRefNum, const Char *output, LedProc ledProc) { gStdioVolRefNum = volRefNum; - + if (ledProc) gStdioLedProc = ledProc; else gStdioLedProc = dummy; - + VFSFileDelete(gStdioVolRefNum, output); VFSFileCreate(gStdioVolRefNum, output); VFSFileOpen (gStdioVolRefNum, output,vfsModeWrite, &gStdioOutput); @@ -48,7 +48,7 @@ void StdioRelease() { UInt16 fclose(FileRef *stream) { Err error = VFSFileClose(*stream); - + if (error == errNone) MemPtrFree(stream); @@ -89,7 +89,7 @@ Int16 fgetc(FileRef *stream) { UInt32 numBytesRead; Err e; Char c; - + e = VFSFileRead(*stream, 1, &c, &numBytesRead); return (int)(!e ? c : EOF); } @@ -102,14 +102,14 @@ Char *fgets(Char *s, UInt32 n, FileRef *stream) { if (error == errNone || error == vfsErrFileEOF) { UInt32 reset = 0; Char *endLine = StrChr(s, '\n'); - + if (endLine >= s) { reset = (endLine - s); s[reset] = 0; reset = numBytesRead - (reset + 1); VFSFileSeek(*stream, vfsOriginCurrent, -reset); } - + return s; } #ifdef _DEBUG_STDIO @@ -143,7 +143,7 @@ FileRef *fopen(const Char *filename, const Char *type) { Err err; UInt16 openMode; FileRef *fileRefP = (FileRef *)MemPtrNew(sizeof(FileRef *)); - + if (StrCompare(type,"r")==0) openMode = vfsModeRead; else if (StrCompare(type,"rb")==0) @@ -280,7 +280,7 @@ UInt32 ftell(FileRef *stream) { e = VFSFileTell(*stream,&filePos); if (e != errNone) return e; - + return filePos; } @@ -323,7 +323,7 @@ Int32 sprintf(Char* s, const Char* formatStr, ...) { va_start(va, formatStr); count = vsprintf(s, formatStr, va); va_end(va); - + return count; } @@ -335,7 +335,7 @@ Int32 snprintf(Char* s, UInt32 len, const Char* formatStr, ...) { va_start(va, formatStr); count = vsprintf(s, formatStr, va); va_end(va); - + return count; } @@ -354,11 +354,11 @@ static Char *StrIToBase(Char *s, Int32 i, UInt8 b) { Char o; Int16 c, n = 0; Int32 div, mod; - + do { div = i / b; mod = i % b; - + s[n++] = *(conv + mod); i = div; @@ -384,7 +384,7 @@ static Char *StrIToBase(Char *s, Int32 i, UInt8 b) { static void StrProcC_(Char *ioStr, UInt16 maxLen) { Char *found; Int16 length; - + while (found = StrStr(ioStr, "`c`")) { if (found[3] == 0) { // if next char is NULL length = maxLen - (found - ioStr + 2); @@ -398,10 +398,10 @@ static void StrProcXO(Char *ioStr, UInt16 maxLen, Char *tmp) { Char *found, *last, mod, fill; Int16 len, count, next; Int32 val; - + while (found = StrChr(ioStr, '`')) { last = StrChr(found + 1, '`'); - + if (!last) return; @@ -417,7 +417,7 @@ static void StrProcXO(Char *ioStr, UInt16 maxLen, Char *tmp) { // x and X always 8char on palmos ... o set to 8char (not supported on palmos) while (found[next] == '0' || found[next] == ' ') // WARNING : reduce size only (TODO ?) next++; - + // convert to base 8 if (mod == 'o') { StrNCopy(tmp, found + next, 8 - next); @@ -434,7 +434,7 @@ static void StrProcXO(Char *ioStr, UInt16 maxLen, Char *tmp) { if ((8 - next) > count) count = 8 - next; - + if (count == 0) count = 1; @@ -455,12 +455,12 @@ static void StrProcXO(Char *ioStr, UInt16 maxLen, Char *tmp) { Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { Char format[256], result[256], tmp[32]; - + Char *found, *mod, *num; UInt32 next; Boolean zero; Int16 count, len; - + MemSet(format, sizeof(format), 'x'); MemSet(result, sizeof(result), 'y'); MemSet(tmp, sizeof(tmp), 'z'); @@ -470,7 +470,7 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { while (found = StrChr(format + next, '%')) { mod = found + 1; - + if (*mod == '%') { // just a % ? mod++; @@ -479,7 +479,7 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { *mod == '-' || *mod == ' ' ) // skip mod++; - + if (*mod == '0' || *mod == '.' ) { *mod++ = '0'; @@ -487,12 +487,12 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { } else { zero = false; } - + num = mod; while ( *mod >= '0' && *mod <= '9' ) // search format char mod++; - + // get the numeric value if (num < mod) { StrNCopy(tmp, num, mod - num); @@ -514,19 +514,19 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { } else { len = 0; - + switch (*mod) { case 'x': case 'X': case 'o': tmp[0] = '`'; tmp[1] = (zero) ? '0' : ' '; - tmp[2] = *mod; + tmp[2] = *mod; StrIToA(tmp + 3, count); len += StrLen(tmp); tmp[len++] = '`'; tmp[len] = 0; - + if (*mod == 'o') { // set as base 10 num and convert later *mod = 'd'; count = 8; // force 8char @@ -534,7 +534,7 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { break; } - + StrNCopy(tmp + len, found, (num - found)); len += (num - found); @@ -542,12 +542,12 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { StrIToA(tmp + len, count); len += StrLen(tmp + len); } - + if (*mod == 'd' || *mod == 'i' || *mod == 'x' || *mod == 'X' || - *mod == 'u' + *mod == 'u' ) { tmp[len++] = 'l'; } @@ -561,15 +561,15 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) { StrNCopy(found, tmp, StrLen(tmp)); mod = found + StrLen(tmp); } - + next = (mod - format); } - + // Copy result in a temp buffer to process last formats StrVPrintF(result, format, argParam); StrProcC_(result, 256); StrProcXO(result, 256, tmp); StrCopy(s, result); - + return StrLen(s); } diff --git a/backends/PalmOS/Src/missing/_stdlib.cpp b/backends/PalmOS/Src/missing/_stdlib.cpp index b56740c3e3..e91f9eb93c 100644 --- a/backends/PalmOS/Src/missing/_stdlib.cpp +++ b/backends/PalmOS/Src/missing/_stdlib.cpp @@ -24,21 +24,21 @@ void *bsearch(const void *key, const void *base, UInt32 nmemb, UInt32 size, int (*compar)(const void *, const void *)) { Int32 position; - + if (SysBinarySearch(base, nmemb, size, (SearchFuncPtr)compar, key, 0, &position, true)) return (void *)((UInt32)base + size * position); - + return NULL; } long strtol(const char *s, char **endptr, int base) { // WARNING : only base = 10 supported long val = StrAToI(s); - + if (endptr) { Char str[maxStrIToALen]; StrIToA(str, val); - + if (StrNCompare(s, str, StrLen(str)) == 0) *endptr = (char *)s + StrLen(str); } @@ -65,18 +65,18 @@ Err free(MemPtr memP) { } MemPtr realloc(MemPtr oldP, UInt32 size) { - + if (oldP != NULL) if (MemPtrResize(oldP,size) == 0) return oldP; MemPtr newP = MemPtrNew(size); - + if (oldP!=NULL) { MemMove(newP,oldP,MemPtrSize(oldP)); MemPtrFree(oldP); - } + } return newP; } diff --git a/backends/PalmOS/Src/missing/_string.cpp b/backends/PalmOS/Src/missing/_string.cpp index 5cd967c0c3..06d5911433 100644 --- a/backends/PalmOS/Src/missing/_string.cpp +++ b/backends/PalmOS/Src/missing/_string.cpp @@ -27,14 +27,14 @@ void *memchr(const void *s, int c, UInt32 n) { for(chr = 0; chr < n;chr++,((UInt8 *)s)++) if ( *((UInt8 *)s) == c) return (void *)s; - + return NULL; } UInt32 strspn(const char *s1, const char *s2) { UInt32 chr = 0; - while ( chr < strlen(s1) && + while ( chr < strlen(s1) && strchr(s2, s1[chr]) ) chr++; @@ -88,13 +88,13 @@ Char *strtok(Char *str, const Char *sep) { Char *strpbrk(const Char *s1, const Char *s2) { Char *found; UInt32 n; - + for (n=0; n <= StrLen(s2); n++) { found = StrChr(s1, s2[n]); if (found) return found; } - + return NULL; } @@ -107,7 +107,7 @@ Char *strrchr(const Char *s, int c) { return (Char *)(s+chr); return NULL; -} +} Char *strdup(const Char *s1) { Char* buf = (Char *)MemPtrNew(StrLen(s1)+1); diff --git a/backends/PalmOS/Src/missing/_time.cpp b/backends/PalmOS/Src/missing/_time.cpp index 01bd96dc5e..14c3f4fe33 100644 --- a/backends/PalmOS/Src/missing/_time.cpp +++ b/backends/PalmOS/Src/missing/_time.cpp @@ -29,10 +29,10 @@ time_t time(time_t *tloc) { DateTimeType Epoch = {1, 0, 0, 1, 1, 1970, 0}; // form 1/1/1904 12AM to 1/1/1970 12AM secs -= TimDateTimeToSeconds (&Epoch); - + if (tloc) *tloc = secs; - + return (secs); } @@ -47,7 +47,7 @@ struct tm *localtime(const time_t *timer) { secs += TimDateTimeToSeconds(&Epoch); TimSecondsToDateTime (secs, &dt); - + tmDate.tm_sec = dt.second; tmDate.tm_min = dt.minute; tmDate.tm_hour = dt.hour; @@ -55,6 +55,6 @@ struct tm *localtime(const time_t *timer) { tmDate.tm_mon = dt.month - 1; tmDate.tm_year = dt.year - 1900; tmDate.tm_wday = dt.weekDay; - + return &tmDate; } diff --git a/backends/PalmOS/Src/missing/_unistd.cpp b/backends/PalmOS/Src/missing/_unistd.cpp index 4b777699cd..92e87595be 100644 --- a/backends/PalmOS/Src/missing/_unistd.cpp +++ b/backends/PalmOS/Src/missing/_unistd.cpp @@ -27,7 +27,7 @@ const Char *gUnistdCWD = NULL; // currently used only to retreive savepath Char *getcwd(Char *buf, UInt32 size) { Char *copy = buf; - + if (gUnistdCWD) { if (!copy) copy = (Char *)MemPtrNew(StrLen(gUnistdCWD)); // this may never occured diff --git a/backends/PalmOS/Src/missing/memory.h b/backends/PalmOS/Src/missing/memory.h index e892182f6c..8fba12584e 100644 --- a/backends/PalmOS/Src/missing/memory.h +++ b/backends/PalmOS/Src/missing/memory.h @@ -19,5 +19,5 @@ * $Header$ * */ - + #include "string.h"
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/stdio.h b/backends/PalmOS/Src/missing/stdio.h index c513d8b951..9bf269f0d6 100644 --- a/backends/PalmOS/Src/missing/stdio.h +++ b/backends/PalmOS/Src/missing/stdio.h @@ -43,8 +43,8 @@ typedef UInt32 size_t; #define vsnprintf(a,b,c,d) vsprintf(a,c,d) #define getc(a) fgetc(a) -#define SEEK_SET vfsOriginBeginning -#define SEEK_CUR vfsOriginCurrent +#define SEEK_SET vfsOriginBeginning +#define SEEK_CUR vfsOriginCurrent #define SEEK_END vfsOriginEnd UInt16 fclose (FileRef *stream); diff --git a/backends/PalmOS/Src/missing/unistd.h b/backends/PalmOS/Src/missing/unistd.h index d94635b7e9..ca43602c37 100644 --- a/backends/PalmOS/Src/missing/unistd.h +++ b/backends/PalmOS/Src/missing/unistd.h @@ -27,6 +27,6 @@ extern const Char *gUnistdCWD; -Char *getcwd(Char *buf, UInt32 size); +Char *getcwd(Char *buf, UInt32 size); #endif
\ No newline at end of file |