forked from pymssql/pymssql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement a bunch more db -> python converters (getting so close to c…
…ompletion)
- Loading branch information
damoxc
committed
Mar 3, 2010
1 parent
f8fc77c
commit 9cead17
Showing
4 changed files
with
210 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int rmv_lcl(char *s, char *buf, size_t buflen) { | ||
char c, *lastsep = NULL, *p = s, *b = buf; | ||
size_t l; | ||
|
||
if (b == (char *)NULL) return 0; | ||
|
||
if (s == (char *)NULL) { | ||
*b = 0; | ||
return 0; | ||
} | ||
|
||
/* find last separator and length of s */ | ||
while ((c = *p)) { | ||
if ((c == '.') || (c == ',')) lastsep = p; | ||
++p; | ||
} | ||
|
||
l = p - s; // strlen(s) | ||
if (buflen < l) return 0; | ||
|
||
/* copy the number skipping all but last separator and all other chars */ | ||
p = s; | ||
while ((c = *p)) { | ||
if (((c >= '0') && (c <= '9')) || (c == '-') || (c == '+')) | ||
*b++ = c; | ||
else if (p == lastsep) | ||
*b++ = '.'; | ||
++p; | ||
} | ||
|
||
*b = 0; | ||
|
||
// cast to int to make x64 happy, can do it because numbers are not so very long | ||
return (int)(b - buf); // return new len | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters