[Rd] Assistance much appreciated

Michael Felt aixtools at gmail.com
Mon Dec 21 18:44:55 CET 2015


On 2015-12-18 09:26, Michael Felt wrote:
> int
> tre_regcomp(regex_t *preg, const char *regex, int cflags)
> {
> return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
> }
I wonder if it could be
Looking here, I saw this line - and I am wondering if L'0' as 64-bit is 
too long, compared to 32-bit, especially since I read somnewhere that 
the strings are being processed byte by byte. (note: on Linux L'0' is 
the same size in both 32 and 64-bit objects).


+3562 wregex[wlen] = L'\0';
+3563 ret = tre_compile(preg, wregex, wlen, cflags);
+3564 free(wregex);
+3565
+3566
+3567
+3568
+3569 return ret;
+3570 }
+3571
"regcomp.i" The cursor is at line 3570 of 3644 --97%-- .


From:
+102 #endif /* TRE_MULTIBYTE */
+103
+104 wregex[wlen] = L'\0';
+105 ret = tre_compile(preg, wregex, wlen, cflags);
+106 xfree(wregex);
+107 #else /* !TRE_WCHAR */
+108 ret = tre_compile(preg, (const tre_char_t *)regex, n, cflags);
+109 #endif /* !TRE_WCHAR */
+110
+111 return ret;
+112 }
"regcomp.c" [Modified] The cursor is at line 112 of 188 --59%-- .
To test for possible differences between AIX 32-bit and AIX 64-bit I 
tried the following program

michael at x071:[/data/prj/cran/tests]cat sizes.c
main()
{
int s0 = sizeof((char) 0);
int s1 = sizeof(0);
int s2 = sizeof('0');
int s3 = sizeof(L'0');

printf("s1: sizeof((char) 0)\t%d\n",s0);
printf("s1: sizeof(0)\t\t%d\n",s1);
printf("s2: sizeof('0')\t\t%d\n",s2);
printf("s3: sizeof(L'0')\t%d\n",s3);
}

On POWER with gcc (Debian)

root at x066:/data/prj/cran/tests# gcc -m32 sizes.c -o sizes
sizes.c: In function ‘main’:
sizes.c:8:2: warning: incompatible implicit declaration of built-in 
function ‘printf’ [enabled by default]
root at x066:/data/prj/cran/tests# ./sizes
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 4
root at x066:/data/prj/cran/tests# gcc -m64 sizes.c -o sizes
sizes.c: In function ‘main’:
sizes.c:8:2: warning: incompatible implicit declaration of built-in 
function ‘printf’ [enabled by default]
root at x066:/data/prj/cran/tests# ./sizes
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 4

On POWER AIX and gcc:
root at x065:[/data/prj/cran/tests]gcc -maix32 -o sizes_32 sizes.c
sizes.c: In function 'main':
sizes.c:8:2: warning: incompatible implicit declaration of built-in 
function 'printf' [enabled by default]
root at x065:[/data/prj/cran/tests]gcc -maix64 -o sizes_64 sizes.c
sizes.c: In function 'main':
sizes.c:8:2: warning: incompatible implicit declaration of built-in 
function 'printf' [enabled by default]
root at x065:[/data/prj/cran/tests]./sizes_32
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 2
root at x065:[/data/prj/cran/tests]./sizes_64
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 4

On AIX and xlc

michael at x071:[/data/prj/cran/tests]xlc -q32 -o sizes_32xlc sizes.c
michael at x071:[/data/prj/cran/tests]./sizes_32xlc
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 2
michael at x071:[/data/prj/cran/tests]xlc -q64 -o sizes_64xlc sizes.c
michael at x071:[/data/prj/cran/tests]./sizes_64xlc
s1: sizeof((char) 0) 1
s1: sizeof(0) 4
s2: sizeof('0') 4
s3: sizeof(L'0') 4



More information about the R-devel mailing list