1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1985-2011 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * Glenn Fowler <gsf@research.att.com> * 18 * David Korn <dgk@research.att.com> * 19 * Phong Vo <kpv@research.att.com> * 20 * * 21 ***********************************************************************/ 22 #pragma prototyped 23 24 /* 25 * Glenn Fowler 26 * AT&T Research 27 * 28 * copy table with element size n 29 * indexed by CC_ASCII to table 30 * indexed by CC_NATIVE 31 */ 32 33 #include <ast.h> 34 #include <ccode.h> 35 36 void* 37 ccnative(void* b, const void* a, size_t n) 38 { 39 #if CC_ASCII == CC_NATIVE 40 return memcpy(b, a, n * (UCHAR_MAX + 1)); 41 #else 42 register int c; 43 register const unsigned char* m; 44 register unsigned char* cb = (unsigned char*)b; 45 register unsigned char* ca = (unsigned char*)a; 46 47 m = CCMAP(CC_ASCII, CC_NATIVE); 48 if (n == sizeof(char)) 49 for (c = 0; c <= UCHAR_MAX; c++) 50 cb[c] = ca[m[c]]; 51 else 52 for (c = 0; c <= UCHAR_MAX; c++) 53 memcpy(cb + n * c, ca + n * m[c], n); 54 return b; 55 #endif 56 } 57