Anonymous avatar Anonymous committed e20413b

- apply same CS everywhere

Comments (0)

Files changed (141)

cmake/modules/TestForHighBitCharacters.c

 
 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 int
-  main ()
+main ()
 {
-   int i;
-   for (i = 0; i < 256; i++)
-     if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i))
-       exit(1);
-   exit (0);
+	int i;
+	for (i = 0; i < 256; i++)
+		if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i))
+			exit(1);
+	exit (0);
 }
 
 int main()
 {
- 	gdImagePtr im;
+	gdImagePtr im;
 	FILE *fp;
 	int cor_rad = 60;
 	im = gdImageCreateTrueColor(400, 400);

examples/copyrotated.c

 
 int main(int argc, char **arg)
 {
- 	gdImagePtr im, im2;
- 	int new_width, new_height;
- 	double angle, a2;
+	gdImagePtr im, im2;
+	int new_width, new_height;
+	double angle, a2;
 
 	if (argc < 3) {
 		fprintf(stderr, "Usage: copyrotated [angle in degree] [filename.png]\n");
 	a2 = angle * .0174532925;
 
 	new_width = ceil(cos(a2) * gdImageSX(im)) +
-				 fabs(sin(a2) * gdImageSY(im));
+	            fabs(sin(a2) * gdImageSY(im));
 	new_height = ceil(cos(a2) * gdImageSY(im)) +
-				 fabs(sin(a2) * gdImageSX(im));
+	             fabs(sin(a2) * gdImageSX(im));
 
 
 	im2 = gdImageCreateTrueColor(new_width, new_height);
 
 int main()
 {
- 	gdImagePtr im, im2;
+	gdImagePtr im, im2;
 
 	im = gdImageCreateTrueColor(400, 400);
 
 
 int main(int argc, char **arg)
 {
- 	gdImagePtr im;
- 	int returncode = 0;
+	gdImagePtr im;
+	int returncode = 0;
 
 	if (argc < 2) {
 		fprintf(stderr, "Usage: flip [filename.png]\n");
 	}
 
 	gdImageColorAllocate(im, 255, 255, 255); /* allocate white as side effect */
-   gdImageGifAnimBegin(im, out, 1, -1);
+	gdImageGifAnimBegin(im, out, 1, -1);
 
 	for(i = 0; i < 20; i++) {
 		int r,g,b;

examples/nnquant.c

 int main()
 {
 #ifdef HAVE_JPEG
- 	gdImagePtr im, im2;
+	gdImagePtr im, im2;
 	FILE *fp;
 	char path[2048];
 

examples/tgaread.c

 /* $Id$ */
 /*
  * You can fetch a set of samples TIFF images here:
- * ftp://ftp.remotesensing.org/pub/libtiff/ 
+ * ftp://ftp.remotesensing.org/pub/libtiff/
  * (pics-x.y.z.tar.gz)
  */
 
 
 int main()
 {
- 	gdImagePtr im;
+	gdImagePtr im;
 	FILE *fp;
 	char path[4][2048];
 	int i;

examples/tiffread.c

 /* $Id$ */
 /*
  * You can fetch a set of samples TIFF images here:
- * ftp://ftp.remotesensing.org/pub/libtiff/ 
+ * ftp://ftp.remotesensing.org/pub/libtiff/
  * (pics-x.y.z.tar.gz)
  */
 
 #include <stdlib.h>
 int main()
 {
- 	gdImagePtr im;
+	gdImagePtr im;
 	FILE *fp;
 	char path[9][2048];
 	int i;

examples/windows.c

 	height = sy;
 	rowptr = buffer;
 	if (stride < 0) {
-		 int startoff = (height - 1) * stride;
-		 rowptr = buffer - startoff;
+		int startoff = (height - 1) * stride;
+		rowptr = buffer - startoff;
 	}
 
 	i = 0;
 	while (height--) {
-		 im->tpixels[i] = rowptr;
-		 rowptr += stride;
-		 i++;
+		im->tpixels[i] = rowptr;
+		rowptr += stride;
+		i++;
 	}
 
 	im->sx = sx;
 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     PSTR szCmdLine, int iCmdShow)
 {
-     static TCHAR szAppName[] = TEXT ("Bezier") ;
-     HWND         hwnd ;
-     MSG          msg ;
-     WNDCLASS     wndclass ;
-
-     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
-     wndclass.lpfnWndProc   = WndProc ;
-     wndclass.cbClsExtra    = 0 ;
-     wndclass.cbWndExtra    = 0 ;
-     wndclass.hInstance     = hInstance ;
-     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
-     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
-     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
-     wndclass.lpszMenuName  = NULL ;
-     wndclass.lpszClassName = szAppName ;
-
-     if (!RegisterClass (&wndclass))
-     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit
-          MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"),
-                      szAppName, MB_ICONERROR) ;
-          return 0 ;
-     }
-
-     hwnd = CreateWindow (szAppName, TEXT ("Bezierkurven"),
-                          WS_OVERLAPPEDWINDOW,
-                          CW_USEDEFAULT, CW_USEDEFAULT,
-                          CW_USEDEFAULT, CW_USEDEFAULT,
-                          NULL, NULL, hInstance, NULL) ;
-
-     ShowWindow (hwnd, iCmdShow) ;
-     UpdateWindow (hwnd) ;
-
-     while (GetMessage (&msg, NULL, 0, 0))
-     {
-          TranslateMessage (&msg) ;
-          DispatchMessage (&msg) ;
-     }
-     return msg.wParam ;
+	static TCHAR szAppName[] = TEXT ("Bezier") ;
+	HWND         hwnd ;
+	MSG          msg ;
+	WNDCLASS     wndclass ;
+
+	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
+	wndclass.lpfnWndProc   = WndProc ;
+	wndclass.cbClsExtra    = 0 ;
+	wndclass.cbWndExtra    = 0 ;
+	wndclass.hInstance     = hInstance ;
+	wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
+	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
+	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
+	wndclass.lpszMenuName  = NULL ;
+	wndclass.lpszClassName = szAppName ;
+
+	if (!RegisterClass (&wndclass)) {
+		// UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit
+		MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"),
+		            szAppName, MB_ICONERROR) ;
+		return 0 ;
+	}
+
+	hwnd = CreateWindow (szAppName, TEXT ("Bezierkurven"),
+	                     WS_OVERLAPPEDWINDOW,
+	                     CW_USEDEFAULT, CW_USEDEFAULT,
+	                     CW_USEDEFAULT, CW_USEDEFAULT,
+	                     NULL, NULL, hInstance, NULL) ;
+
+	ShowWindow (hwnd, iCmdShow) ;
+	UpdateWindow (hwnd) ;
+
+	while (GetMessage (&msg, NULL, 0, 0)) {
+		TranslateMessage (&msg) ;
+		DispatchMessage (&msg) ;
+	}
+	return msg.wParam ;
 }
 
 void DrawBezier (HDC hdc, POINT apt[])
 {
-     PolyBezier (hdc, apt, 4) ;
+	PolyBezier (hdc, apt, 4) ;
 
-     MoveToEx (hdc, apt[0].x, apt[0].y, NULL) ;
-     LineTo   (hdc, apt[1].x, apt[1].y) ;
+	MoveToEx (hdc, apt[0].x, apt[0].y, NULL) ;
+	LineTo   (hdc, apt[1].x, apt[1].y) ;
 
-     MoveToEx (hdc, apt[2].x, apt[2].y, NULL) ;
-     LineTo   (hdc, apt[3].x, apt[3].y) ;
+	MoveToEx (hdc, apt[2].x, apt[2].y, NULL) ;
+	LineTo   (hdc, apt[3].x, apt[3].y) ;
 }
 
 
 void gdDrawImage(HDC hdc, RECT *rc)
 {
-    HDC  mem_dc;
+	HDC  mem_dc;
 	BITMAPINFO bmp_info;
 	void* bits;
 	HBITMAP bmp, temp;
 	gdImageLine(im, 0, 0, 150, 150, black);
 
 	gdImageString(im, gdFontGetLarge(),
-	im->sx / 2 - (strlen(s) * lfont->w / 2),
-	im->sy / 2 - lfont->h / 2,
-	(unsigned char*)s, black);
+	              im->sx / 2 - (strlen(s) * lfont->w / 2),
+	              im->sy / 2 - lfont->h / 2,
+	              (unsigned char*)s, black);
 
 	// Copy drawing from memory context (shared bitmap buffer) to screen DC.
 	BitBlt(hdc, rc->left, rc->top, width, height, mem_dc, 0, 0, SRCCOPY);
 
 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
-     static POINT apt[4] ;
-     HDC          hdc ;
-     int          cxClient, cyClient ;
-     PAINTSTRUCT  ps ;
-     RECT rc;
+	static POINT apt[4] ;
+	HDC          hdc ;
+	int          cxClient, cyClient ;
+	PAINTSTRUCT  ps ;
+	RECT rc;
 
 	GetClientRect(hwnd, &rc);
 
-     switch (message)
-	 {
-     case WM_SIZE:
-          cxClient = LOWORD (lParam) ;
-          cyClient = HIWORD (lParam) ;
-
-          apt[0].x = cxClient / 4 ;
-          apt[0].y = cyClient / 2 ;
-
-          apt[1].x = cxClient / 2 ;
-          apt[1].y = cyClient / 4 ;
-
-          apt[2].x =     cxClient / 2 ;
-          apt[2].y = 3 * cyClient / 4 ;
-
-          apt[3].x = 3 * cxClient / 4 ;
-          apt[3].y =     cyClient / 2 ;
-          return 0 ;
-
-     case WM_LBUTTONDOWN:
-     case WM_RBUTTONDOWN:
-     case WM_MOUSEMOVE:
-          if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
-          {
-               hdc = GetDC (hwnd) ;
-
-               // alte Kurve löschen (mit Weiß übermalen)
-               SelectObject (hdc, GetStockObject (WHITE_PEN)) ;
-               DrawBezier (hdc, apt) ;
-
-               if (wParam & MK_LBUTTON)
-               {
-                    apt[1].x = LOWORD (lParam) ;
-                    apt[1].y = HIWORD (lParam) ;
-               }
-
-                if (wParam & MK_RBUTTON)
-               {
-                    apt[2].x = LOWORD (lParam) ;
-                    apt[2].y = HIWORD (lParam) ;
-               }
-
-               // neue Kurve (mit Schwarz) zeichnen
-			   SelectObject (hdc, GetStockObject (BLACK_PEN)) ;
-				gdDrawImage(hdc, &rc);
-               DrawBezier (hdc, apt) ;
-               ReleaseDC (hwnd, hdc) ;
-          }
-          return 0 ;
-
-
-     case WM_PAINT:
+	switch (message) {
+	case WM_SIZE:
+		cxClient = LOWORD (lParam) ;
+		cyClient = HIWORD (lParam) ;
+
+		apt[0].x = cxClient / 4 ;
+		apt[0].y = cyClient / 2 ;
+
+		apt[1].x = cxClient / 2 ;
+		apt[1].y = cyClient / 4 ;
+
+		apt[2].x =     cxClient / 2 ;
+		apt[2].y = 3 * cyClient / 4 ;
+
+		apt[3].x = 3 * cxClient / 4 ;
+		apt[3].y =     cyClient / 2 ;
+		return 0 ;
+
+	case WM_LBUTTONDOWN:
+	case WM_RBUTTONDOWN:
+	case WM_MOUSEMOVE:
+		if (wParam & MK_LBUTTON || wParam & MK_RBUTTON) {
+			hdc = GetDC (hwnd) ;
+
+			// alte Kurve löschen (mit Weiß übermalen)
+			SelectObject (hdc, GetStockObject (WHITE_PEN)) ;
+			DrawBezier (hdc, apt) ;
+
+			if (wParam & MK_LBUTTON) {
+				apt[1].x = LOWORD (lParam) ;
+				apt[1].y = HIWORD (lParam) ;
+			}
+
+			if (wParam & MK_RBUTTON) {
+				apt[2].x = LOWORD (lParam) ;
+				apt[2].y = HIWORD (lParam) ;
+			}
+
+			// neue Kurve (mit Schwarz) zeichnen
+			SelectObject (hdc, GetStockObject (BLACK_PEN)) ;
+			gdDrawImage(hdc, &rc);
+			DrawBezier (hdc, apt) ;
+			ReleaseDC (hwnd, hdc) ;
+		}
+		return 0 ;
+
+
+	case WM_PAINT:
 		hdc = BeginPaint (hwnd, &ps) ;
 
 		GetClientRect(hwnd, &rc);
 		EndPaint (hwnd, &ps) ;
 		return 0 ;
 
-     case WM_DESTROY:
-          PostQuitMessage (0) ;
-          return 0 ;
-     }
-     return DefWindowProc (hwnd, message, wParam, lParam) ;
+	case WM_DESTROY:
+		PostQuitMessage (0) ;
+		return 0 ;
+	}
+	return DefWindowProc (hwnd, message, wParam, lParam) ;
 }

netware/keepscreen.c

-/* Simple _NonAppStop() implementation which can be linked to your 
+/* Simple _NonAppStop() implementation which can be linked to your
  * NLM in order to keep the screen open when the NLM terminates
  * (the good old clib behaviour).
  * You dont have to call it, its done automatically from LibC.
  *
- * 2004-Aug-11  by Guenter Knauf 
+ * 2004-Aug-11  by Guenter Knauf
  *
  * URL: http://www.gknw.com/development/mk_nlm/
  *
  * $Id$
  */
- 
+
 #include <stdio.h>
 #include <screen.h>
 
 void _NonAppStop()
 {
-    uint16_t row, col;
-    
-    GetScreenSize(&row, &col);
-    gotorowcol(row-1, 0);
-    /* pressanykey(); */
-    printf("<Press any key to close screen> ");
-    getcharacter();
+	uint16_t row, col;
+
+	GetScreenSize(&row, &col);
+	gotorowcol(row-1, 0);
+	/* pressanykey(); */
+	printf("<Press any key to close screen> ");
+	getcharacter();
 }
 
 
 #include <nks/synch.h>
 
 
-typedef struct
-{
-    int     _errno;
-    void    *twentybytes;
+typedef struct {
+	int     _errno;
+	void    *twentybytes;
 } libthreaddata_t;
 
-typedef struct
-{
-    int         x;
-    int         y;
-    int         z;
-    void        *tenbytes;
-    NXKey_t     perthreadkey;   /* if -1, no key obtained... */
-    NXMutex_t   *lock;
+typedef struct {
+	int         x;
+	int         y;
+	int         z;
+	void        *tenbytes;
+	NXKey_t     perthreadkey;   /* if -1, no key obtained... */
+	NXMutex_t   *lock;
 } libdata_t;
 
 int         gLibId      = -1;
     size_t      uninitializedDataLength,
     void        *NLMFileHandle,
     int         (*readRoutineP)( int conn, void *fileHandle, size_t offset,
-                                size_t nbytes, size_t *bytesRead, void *buffer ),
+                                 size_t nbytes, size_t *bytesRead, void *buffer ),
     size_t      customDataOffset,
     size_t      customDataSize,
     int         messageCount,
     const char  **messages
 )
 {
-    NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
+	NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
 
 #ifndef __GNUC__
 #pragma unused(cmdLine)
 #pragma unused(messages)
 #endif
 
-/*
-** Here we process our command line, post errors (to the error screen),
-** perform initializations and anything else we need to do before being able
-** to accept calls into us. If we succeed, we return non-zero and the NetWare
-** Loader will leave us up, otherwise we fail to load and get dumped.
-*/
-    gAllocTag = AllocateResourceTag(NLMHandle,
-                                "<library-name> memory allocations", AllocSignature);
+	/*
+	** Here we process our command line, post errors (to the error screen),
+	** perform initializations and anything else we need to do before being able
+	** to accept calls into us. If we succeed, we return non-zero and the NetWare
+	** Loader will leave us up, otherwise we fail to load and get dumped.
+	*/
+	gAllocTag = AllocateResourceTag(NLMHandle,
+	                                "<library-name> memory allocations", AllocSignature);
 
-    if (!gAllocTag)
-    {
-        OutputToScreen(errorScreen, "Unable to allocate resource tag for "
-                                            "library memory allocations.\n");
-        return -1;
-    }
+	if (!gAllocTag) {
+		OutputToScreen(errorScreen, "Unable to allocate resource tag for "
+		               "library memory allocations.\n");
+		return -1;
+	}
 
-    gLibId = register_library(DisposeLibraryData);
+	gLibId = register_library(DisposeLibraryData);
 
-    if (gLibId < -1)
-    {
-        OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
-        return -1;
-    }
+	if (gLibId < -1) {
+		OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
+		return -1;
+	}
 
-    gLibHandle = NLMHandle;
+	gLibHandle = NLMHandle;
 
-    gLibLock = NXMutexAlloc(0, 0, &liblock);
+	gLibLock = NXMutexAlloc(0, 0, &liblock);
 
-    if (!gLibLock)
-    {
-        OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
-        return -1;
-    }
+	if (!gLibLock) {
+		OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
+		return -1;
+	}
 
-    return 0;
+	return 0;
 }
 
 /*
 */
 void _NonAppStop( void )
 {
-    (void) unregister_library(gLibId);
-    NXMutexFree(gLibLock);
+	(void) unregister_library(gLibId);
+	NXMutexFree(gLibLock);
 }
 
 /*
 */
 int  _NonAppCheckUnload( void )
 {
-    return 0;
+	return 0;
 }
 
 int GetOrSetUpData
     libthreaddata_t **threadData
 )
 {
-    int                 err;
-    libdata_t           *app_data;
-    libthreaddata_t *thread_data;
-    NXKey_t             key;
-    NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
-
-    err         = 0;
-    thread_data = (libthreaddata_t *) NULL;
-
-/*
-** Attempt to get our data for the application calling us. This is where we
-** store whatever application-specific information we need to carry in support
-** of calling applications.
-*/
-    app_data = (libdata_t *) get_app_data(id);
-
-    if (!app_data)
-    {
-/*
-** This application hasn't called us before; set up application AND per-thread
-** data. Of course, just in case a thread from this same application is calling
-** us simultaneously, we better lock our application data-creation mutex. We
-** also need to recheck for data after we acquire the lock because WE might be
-** that other thread that was too late to create the data and the first thread
-** in will have created it.
-*/
-        NXLock(gLibLock);
-
-        if (!(app_data = (libdata_t *) get_app_data(id)))
-        {
-            app_data = (libdata_t *) malloc(sizeof(libdata_t));
-
-            if (app_data)
-            {
-                memset(app_data, 0, sizeof(libdata_t));
-
-                app_data->tenbytes = malloc(10);
-                app_data->lock     = NXMutexAlloc(0, 0, &liblock);
-
-                if (!app_data->tenbytes || !app_data->lock)
-                {
-                    if (app_data->lock)
-                        NXMutexFree(app_data->lock);
-
-                    free(app_data);
-                    app_data = (libdata_t *) NULL;
-                    err      = ENOMEM;
-                }
-
-                if (app_data)
-                {
-/*
-** Here we burn in the application data that we were trying to get by calling
-** get_app_data(). Next time we call the first function, we'll get this data
-** we're just now setting. We also go on here to establish the per-thread data
-** for the calling thread, something we'll have to do on each application
-** thread the first time it calls us.
-*/
-                    err = set_app_data(gLibId, app_data);
-
-                    if (err)
-                    {
-                        free(app_data);
-                        app_data = (libdata_t *) NULL;
-                        err      = ENOMEM;
-                    }
-                    else
-                    {
-                        /* create key for thread-specific data... */
-                        err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
-
-                        if (err)                /* (no more keys left?) */
-                            key = -1;
-
-                        app_data->perthreadkey = key;
-                    }
-                }
-            }
-        }
-
-        NXUnlock(gLibLock);
-    }
-
-    if (app_data)
-    {
-        key = app_data->perthreadkey;
-
-        if (     key != -1                  /* couldn't create a key? no thread data */
-            && !(err = NXKeyGetValue(key, (void **) &thread_data))
-            && !thread_data)
-        {
-/*
-** Allocate the per-thread data for the calling thread. Regardless of whether
-** there was already application data or not, this may be the first call by a
-** a new thread. The fact that we allocation 20 bytes on a pointer is not very
-** important, this just helps to demonstrate that we can have arbitrarily
-** complex per-thread data.
-*/
-            thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
-
-            if (thread_data)
-            {
-                thread_data->_errno      = 0;
-                thread_data->twentybytes = malloc(20);
-
-                if (!thread_data->twentybytes)
-                {
-                    free(thread_data);
-                    thread_data = (libthreaddata_t *) NULL;
-                    err         = ENOMEM;
-                }
-
-                if ((err = NXKeySetValue(key, thread_data)))
-                {
-                    free(thread_data->twentybytes);
-                    free(thread_data);
-                    thread_data = (libthreaddata_t *) NULL;
-                }
-            }
-        }
-    }
-
-    if (appData)
-        *appData = app_data;
-
-    if (threadData)
-        *threadData = thread_data;
-
-    return err;
+	int                 err;
+	libdata_t           *app_data;
+	libthreaddata_t *thread_data;
+	NXKey_t             key;
+	NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
+
+	err         = 0;
+	thread_data = (libthreaddata_t *) NULL;
+
+	/*
+	** Attempt to get our data for the application calling us. This is where we
+	** store whatever application-specific information we need to carry in support
+	** of calling applications.
+	*/
+	app_data = (libdata_t *) get_app_data(id);
+
+	if (!app_data) {
+		/*
+		** This application hasn't called us before; set up application AND per-thread
+		** data. Of course, just in case a thread from this same application is calling
+		** us simultaneously, we better lock our application data-creation mutex. We
+		** also need to recheck for data after we acquire the lock because WE might be
+		** that other thread that was too late to create the data and the first thread
+		** in will have created it.
+		*/
+		NXLock(gLibLock);
+
+		if (!(app_data = (libdata_t *) get_app_data(id))) {
+			app_data = (libdata_t *) malloc(sizeof(libdata_t));
+
+			if (app_data) {
+				memset(app_data, 0, sizeof(libdata_t));
+
+				app_data->tenbytes = malloc(10);
+				app_data->lock     = NXMutexAlloc(0, 0, &liblock);
+
+				if (!app_data->tenbytes || !app_data->lock) {
+					if (app_data->lock)
+						NXMutexFree(app_data->lock);
+
+					free(app_data);
+					app_data = (libdata_t *) NULL;
+					err      = ENOMEM;
+				}
+
+				if (app_data) {
+					/*
+					** Here we burn in the application data that we were trying to get by calling
+					** get_app_data(). Next time we call the first function, we'll get this data
+					** we're just now setting. We also go on here to establish the per-thread data
+					** for the calling thread, something we'll have to do on each application
+					** thread the first time it calls us.
+					*/
+					err = set_app_data(gLibId, app_data);
+
+					if (err) {
+						free(app_data);
+						app_data = (libdata_t *) NULL;
+						err      = ENOMEM;
+					} else {
+						/* create key for thread-specific data... */
+						err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
+
+						if (err)                /* (no more keys left?) */
+							key = -1;
+
+						app_data->perthreadkey = key;
+					}
+				}
+			}
+		}
+
+		NXUnlock(gLibLock);
+	}
+
+	if (app_data) {
+		key = app_data->perthreadkey;
+
+		if (     key != -1                  /* couldn't create a key? no thread data */
+		         && !(err = NXKeyGetValue(key, (void **) &thread_data))
+		         && !thread_data) {
+			/*
+			** Allocate the per-thread data for the calling thread. Regardless of whether
+			** there was already application data or not, this may be the first call by a
+			** a new thread. The fact that we allocation 20 bytes on a pointer is not very
+			** important, this just helps to demonstrate that we can have arbitrarily
+			** complex per-thread data.
+			*/
+			thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
+
+			if (thread_data) {
+				thread_data->_errno      = 0;
+				thread_data->twentybytes = malloc(20);
+
+				if (!thread_data->twentybytes) {
+					free(thread_data);
+					thread_data = (libthreaddata_t *) NULL;
+					err         = ENOMEM;
+				}
+
+				if ((err = NXKeySetValue(key, thread_data))) {
+					free(thread_data->twentybytes);
+					free(thread_data);
+					thread_data = (libthreaddata_t *) NULL;
+				}
+			}
+		}
+	}
+
+	if (appData)
+		*appData = app_data;
+
+	if (threadData)
+		*threadData = thread_data;
+
+	return err;
 }
 
 int DisposeLibraryData
     void    *data
 )
 {
-    if (data)
-    {
-        void    *tenbytes = ((libdata_t *) data)->tenbytes;
+	if (data) {
+		void    *tenbytes = ((libdata_t *) data)->tenbytes;
 
-        if (tenbytes)
-            free(tenbytes);
+		if (tenbytes)
+			free(tenbytes);
 
-        free(data);
-    }
+		free(data);
+	}
 
-    return 0;
+	return 0;
 }
 
 void DisposeThreadData
     void    *data
 )
 {
-    if (data)
-    {
-        void    *twentybytes = ((libthreaddata_t *) data)->twentybytes;
+	if (data) {
+		void    *twentybytes = ((libthreaddata_t *) data)->twentybytes;
 
-        if (twentybytes)
-            free(twentybytes);
+		if (twentybytes)
+			free(twentybytes);
 
-        free(data);
-    }
+		free(data);
+	}
 }
 
 
 #include "gd.h"
 
 /* A neat little utility which adds freetype text to
- * existing JPEG images. Type annotate -h for instructions. 
+ * existing JPEG images. Type annotate -h for instructions.
  * Thanks to Joel Dubiner for supporting this work. -TBB
  */
 
 
 	/* 2.0.12 */
 	fprintf (stderr, "annotate is not useful without freetype.\n"
-		"Install freetype, then './configure; make clean; make install'\n"
-		"the gd library again.\n"
-	);
+	         "Install freetype, then './configure; make clean; make install'\n"
+	         "the gd library again.\n"
+	        );
 	return 1;
 #else
 	gdImagePtr im;
 		fprintf(stderr, "move x y\n");
 		fprintf(stderr, "text actual-output-text\n\n");
 		fprintf(stderr,
-			"If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
+		        "If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
 		fprintf(stderr,
-			"location specified in the GDFONTPATH environment variable, 'font paris' is\n");
+		        "location specified in the GDFONTPATH environment variable, 'font paris' is\n");
 		fprintf(stderr,
-			"sufficient. You may also specify the full, rooted path of a font file.\n");
+		        "sufficient. You may also specify the full, rooted path of a font file.\n");
 		exit(1);
 	}
 
 			color = gdTrueColorAlpha(r, g, b, a);
 		} else if(!strcmp(st, "move")) {
 			char *st = strtok(0, "\r\n");
-	
+
 			if(!st) {
 				goto badLine;
 			}
 			gdImageStringFT(0, bounds, color, font, size, 0, x, y, text);
 
 			switch(align) {
-				case left:
+			case left:
 				break;
 
-				case center:
-					rx -= (bounds[2] - bounds[0]) / 2;
+			case center:
+				rx -= (bounds[2] - bounds[0]) / 2;
 				break;
 
-				case right:
-					rx -= (bounds[2] - bounds[0]);
+			case right:
+				rx -= (bounds[2] - bounds[0]);
 				break;
 			}
 
 extern "C" {
 #endif
 
-/*
-	gd_bmp.c
+	/*
+		gd_bmp.c
 
-	Bitmap format support for libgd
+		Bitmap format support for libgd
 
-	* Written 2007, Scott MacVicar
-	---------------------------------------------------------------------------
+		* Written 2007, Scott MacVicar
+		---------------------------------------------------------------------------
 
-	Todo:
+		Todo:
 
-	RLE4, RLE8 and Bitfield encoding
-	Add full support for Windows v4 and Windows v5 header formats
+		RLE4, RLE8 and Bitfield encoding
+		Add full support for Windows v4 and Windows v5 header formats
 
-	----------------------------------------------------------------------------
- */
+		----------------------------------------------------------------------------
+	 */
 
 #ifndef BMP_H
 #define BMP_H	1
 #define BMP_RLE_TYPE_RAW 0
 #define BMP_RLE_TYPE_RLE 1
 
-/* BMP header. */
-typedef struct
-{
-	/* 16 bit - header identifying the type */
-	signed short int magic;
+	/* BMP header. */
+	typedef struct {
+		/* 16 bit - header identifying the type */
+		signed short int magic;
 
-	/* 32bit - size of the file */
-	int size;
+		/* 32bit - size of the file */
+		int size;
 
-	/* 16bit - these two are in the spec but "reserved" */
-	signed short int reserved1;
-	signed short int reserved2;
+		/* 16bit - these two are in the spec but "reserved" */
+		signed short int reserved1;
+		signed short int reserved2;
 
-	/* 32 bit - offset of the bitmap header from data in bytes */
-	signed int off;
+		/* 32 bit - offset of the bitmap header from data in bytes */
+		signed int off;
 
-} bmp_hdr_t;
+	} bmp_hdr_t;
 
-/* BMP info. */
-typedef struct
-{
-	/* 16bit - Type, ie Windows or OS/2 for the palette info */
-	signed short int type;
-	/* 32bit - The length of the bitmap information header in bytes. */
-	signed int len;
+	/* BMP info. */
+	typedef struct {
+		/* 16bit - Type, ie Windows or OS/2 for the palette info */
+		signed short int type;
+		/* 32bit - The length of the bitmap information header in bytes. */
+		signed int len;
 
-	/* 32bit - The width of the bitmap in pixels. */
-	signed int width;
+		/* 32bit - The width of the bitmap in pixels. */
+		signed int width;
 
-	/* 32bit - The height of the bitmap in pixels. */
-	signed int height;
+		/* 32bit - The height of the bitmap in pixels. */
+		signed int height;
 
-	/* 8 bit - The bitmap data is specified in top-down order. */
-	signed char topdown;
+		/* 8 bit - The bitmap data is specified in top-down order. */
+		signed char topdown;
 
-	/* 16 bit - The number of planes.  This must be set to a value of one. */
-	signed short int numplanes;
+		/* 16 bit - The number of planes.  This must be set to a value of one. */
+		signed short int numplanes;
 
-	/* 16 bit - The number of bits per pixel. */
-	signed short int depth;
+		/* 16 bit - The number of bits per pixel. */
+		signed short int depth;
 
-	/* 32bit - The type of compression used. */
-	signed int enctype;
+		/* 32bit - The type of compression used. */
+		signed int enctype;
 
-	/* 32bit - The size of the image in bytes. */
-	signed int size;
+		/* 32bit - The size of the image in bytes. */
+		signed int size;
 
-	/* 32bit - The horizontal resolution in pixels/metre. */
-	signed int hres;
+		/* 32bit - The horizontal resolution in pixels/metre. */
+		signed int hres;
 
-	/* 32bit - The vertical resolution in pixels/metre. */
-	signed int vres;
+		/* 32bit - The vertical resolution in pixels/metre. */
+		signed int vres;
 
-	/* 32bit - The number of color indices used by the bitmap. */
-	signed int numcolors;
+		/* 32bit - The number of color indices used by the bitmap. */
+		signed int numcolors;
 
-	/* 32bit - The number of color indices important for displaying the bitmap. */
-	signed int mincolors;
+		/* 32bit - The number of color indices important for displaying the bitmap. */
+		signed int mincolors;
 
-} bmp_info_t;
+	} bmp_info_t;
 
 #endif
 

src/circletexttest.c

 	in = fopen("eleanor.jpg", "rb");
 	if(!in) {
 		im = gdImageCreateTrueColor(300, 300);
-    } else {
+	} else {
 		im = gdImageCreateFromJpeg(in);
 		fclose(in);
 	}
 	}
 
 	error = gdImageStringFTCircle(im,
-		gdImageSX(im) / 2, gdImageSY(im) / 2,
-		radius, radius / 2,
-		0.8, "arial", 24, "top text", "bottom text",
-		gdTrueColorAlpha(192, 100, 255, 32)
-	);
+	                              gdImageSX(im) / 2, gdImageSY(im) / 2,
+	                              radius, radius / 2,
+	                              0.8, "arial", 24, "top text", "bottom text",
+	                              gdTrueColorAlpha(192, 100, 255, 32)
+	                             );
 	if(error)  {
 		fprintf(stderr, "gdImageStringFTEx error: %s\n", error);
 	}
 extern "C" {
 #endif
 
-static struct entities_s {
-	char	*name;
-	int	value;
-} entities[] = {
-	{"AElig", 198},
-	{"Aacute", 193},
-	{"Acirc", 194},
-	{"Agrave", 192},
-	{"Alpha", 913},
-	{"Aring", 197},
-	{"Atilde", 195},
-	{"Auml", 196},
-	{"Beta", 914},
-	{"Ccedil", 199},
-	{"Chi", 935},
-	{"Dagger", 8225},
-	{"Delta", 916},
-	{"ETH", 208},
-	{"Eacute", 201},
-	{"Ecirc", 202},
-	{"Egrave", 200},
-	{"Epsilon", 917},
-	{"Eta", 919},
-	{"Euml", 203},
-	{"Gamma", 915},
-	{"Iacute", 205},
-	{"Icirc", 206},
-	{"Igrave", 204},
-	{"Iota", 921},
-	{"Iuml", 207},
-	{"Kappa", 922},
-	{"Lambda", 923},
-	{"Mu", 924},
-	{"Ntilde", 209},
-	{"Nu", 925},
-	{"OElig", 338},
-	{"Oacute", 211},
-	{"Ocirc", 212},
-	{"Ograve", 210},
-	{"Omega", 937},
-	{"Omicron", 927},
-	{"Oslash", 216},
-	{"Otilde", 213},
-	{"Ouml", 214},
-	{"Phi", 934},
-	{"Pi", 928},
-	{"Prime", 8243},
-	{"Psi", 936},
-	{"Rho", 929},
-	{"Scaron", 352},
-	{"Sigma", 931},
-	{"THORN", 222},
-	{"Tau", 932},
-	{"Theta", 920},
-	{"Uacute", 218},
-	{"Ucirc", 219},
-	{"Ugrave", 217},
-	{"Upsilon", 933},
-	{"Uuml", 220},
-	{"Xi", 926},
-	{"Yacute", 221},
-	{"Yuml", 376},
-	{"Zeta", 918},
-	{"aacute", 225},
-	{"acirc", 226},
-	{"acute", 180},
-	{"aelig", 230},
-	{"agrave", 224},
-	{"alefsym", 8501},
-	{"alpha", 945},
-	{"amp", 38},
-	{"and", 8743},
-	{"ang", 8736},
-	{"aring", 229},
-	{"asymp", 8776},
-	{"atilde", 227},
-	{"auml", 228},
-	{"bdquo", 8222},
-	{"beta", 946},
-	{"brvbar", 166},
-	{"bull", 8226},
-	{"cap", 8745},
-	{"ccedil", 231},
-	{"cedil", 184},
-	{"cent", 162},
-	{"chi", 967},
-	{"circ", 710},
-	{"clubs", 9827},
-	{"cong", 8773},
-	{"copy", 169},
-	{"crarr", 8629},
-	{"cup", 8746},
-	{"curren", 164},
-	{"dArr", 8659},
-	{"dagger", 8224},
-	{"darr", 8595},
-	{"deg", 176},
-	{"delta", 948},
-	{"diams", 9830},
-	{"divide", 247},
-	{"eacute", 233},
-	{"ecirc", 234},
-	{"egrave", 232},
-	{"empty", 8709},
-	{"emsp", 8195},
-	{"ensp", 8194},
-	{"epsilon", 949},
-	{"equiv", 8801},
-	{"eta", 951},
-	{"eth", 240},
-	{"euml", 235},
-	{"euro", 8364},
-	{"exist", 8707},
-	{"fnof", 402},
-	{"forall", 8704},
-	{"frac12", 189},
-	{"frac14", 188},
-	{"frac34", 190},
-	{"frasl", 8260},
-	{"gamma", 947},
-	{"ge", 8805},
-	{"gt", 62},
-	{"hArr", 8660},
-	{"harr", 8596},
-	{"hearts", 9829},
-	{"hellip", 8230},
-	{"iacute", 237},
-	{"icirc", 238},
-	{"iexcl", 161},
-	{"igrave", 236},
-	{"image", 8465},
-	{"infin", 8734},
-	{"int", 8747},
-	{"iota", 953},
-	{"iquest", 191},
-	{"isin", 8712},
-	{"iuml", 239},
-	{"kappa", 954},
-	{"lArr", 8656},
-	{"lambda", 955},
-	{"lang", 9001},
-	{"laquo", 171},
-	{"larr", 8592},
-	{"lceil", 8968},
-	{"ldquo", 8220},
-	{"le", 8804},
-	{"lfloor", 8970},
-	{"lowast", 8727},
-	{"loz", 9674},
-	{"lrm", 8206},
-	{"lsaquo", 8249},
-	{"lsquo", 8216},
-	{"lt", 60},
-	{"macr", 175},
-	{"mdash", 8212},
-	{"micro", 181},
-	{"middot", 183},
-	{"minus", 8722},
-	{"mu", 956},
-	{"nabla", 8711},
-	{"nbsp", 160},
-	{"ndash", 8211},
-	{"ne", 8800},
-	{"ni", 8715},
-	{"not", 172},
-	{"notin", 8713},
-	{"nsub", 8836},
-	{"ntilde", 241},
-	{"nu", 957},
-	{"oacute", 243},
-	{"ocirc", 244},
-	{"oelig", 339},
-	{"ograve", 242},
-	{"oline", 8254},
-	{"omega", 969},
-	{"omicron", 959},
-	{"oplus", 8853},
-	{"or", 8744},
-	{"ordf", 170},
-	{"ordm", 186},
-	{"oslash", 248},
-	{"otilde", 245},
-	{"otimes", 8855},
-	{"ouml", 246},
-	{"para", 182},
-	{"part", 8706},
-	{"permil", 8240},
-	{"perp", 8869},
-	{"phi", 966},
-	{"pi", 960},
-	{"piv", 982},
-	{"plusmn", 177},
-	{"pound", 163},
-	{"prime", 8242},
-	{"prod", 8719},
-	{"prop", 8733},
-	{"psi", 968},
-	{"quot", 34},
-	{"rArr", 8658},
-	{"radic", 8730},
-	{"rang", 9002},
-	{"raquo", 187},
-	{"rarr", 8594},
-	{"rceil", 8969},
-	{"rdquo", 8221},
-	{"real", 8476},
-	{"reg", 174},
-	{"rfloor", 8971},
-	{"rho", 961},
-	{"rlm", 8207},
-	{"rsaquo", 8250},
-	{"rsquo", 8217},
-	{"sbquo", 8218},
-	{"scaron", 353},
-	{"sdot", 8901},
-	{"sect", 167},
-	{"shy", 173},
-	{"sigma", 963},
-	{"sigmaf", 962},
-	{"sim", 8764},
-	{"spades", 9824},
-	{"sub", 8834},
-	{"sube", 8838},
-	{"sum", 8721},
-	{"sup", 8835},
-	{"sup1", 185},
-	{"sup2", 178},
-	{"sup3", 179},
-	{"supe", 8839},
-	{"szlig", 223},
-	{"tau", 964},
-	{"there4", 8756},
-	{"theta", 952},
-	{"thetasym", 977},
-	{"thinsp", 8201},
-	{"thorn", 254},
-	{"tilde", 732},
-	{"times", 215},
-	{"trade", 8482},
-	{"uArr", 8657},
-	{"uacute", 250},
-	{"uarr", 8593},
-	{"ucirc", 251},
-	{"ugrave", 249},
-	{"uml", 168},
-	{"upsih", 978},
-	{"upsilon", 965},
-	{"uuml", 252},
-	{"weierp", 8472},
-	{"xi", 958},
-	{"yacute", 253},
-	{"yen", 165},
-	{"yuml", 255},
-	{"zeta", 950},
-	{"zwj", 8205},
-	{"zwnj", 8204},
-};
+	static struct entities_s {
+		char	*name;
+		int	value;
+	} entities[] = {
+		{"AElig", 198},
+		{"Aacute", 193},
+		{"Acirc", 194},
+		{"Agrave", 192},
+		{"Alpha", 913},
+		{"Aring", 197},
+		{"Atilde", 195},
+		{"Auml", 196},
+		{"Beta", 914},
+		{"Ccedil", 199},
+		{"Chi", 935},
+		{"Dagger", 8225},
+		{"Delta", 916},
+		{"ETH", 208},
+		{"Eacute", 201},
+		{"Ecirc", 202},
+		{"Egrave", 200},
+		{"Epsilon", 917},
+		{"Eta", 919},
+		{"Euml", 203},
+		{"Gamma", 915},
+		{"Iacute", 205},
+		{"Icirc", 206},
+		{"Igrave", 204},
+		{"Iota", 921},
+		{"Iuml", 207},
+		{"Kappa", 922},
+		{"Lambda", 923},
+		{"Mu", 924},
+		{"Ntilde", 209},
+		{"Nu", 925},
+		{"OElig", 338},
+		{"Oacute", 211},
+		{"Ocirc", 212},
+		{"Ograve", 210},
+		{"Omega", 937},
+		{"Omicron", 927},
+		{"Oslash", 216},
+		{"Otilde", 213},
+		{"Ouml", 214},
+		{"Phi", 934},
+		{"Pi", 928},
+		{"Prime", 8243},
+		{"Psi", 936},
+		{"Rho", 929},
+		{"Scaron", 352},
+		{"Sigma", 931},
+		{"THORN", 222},
+		{"Tau", 932},
+		{"Theta", 920},
+		{"Uacute", 218},
+		{"Ucirc", 219},
+		{"Ugrave", 217},
+		{"Upsilon", 933},
+		{"Uuml", 220},
+		{"Xi", 926},
+		{"Yacute", 221},
+		{"Yuml", 376},
+		{"Zeta", 918},
+		{"aacute", 225},
+		{"acirc", 226},
+		{"acute", 180},
+		{"aelig", 230},
+		{"agrave", 224},
+		{"alefsym", 8501},
+		{"alpha", 945},
+		{"amp", 38},
+		{"and", 8743},
+		{"ang", 8736},
+		{"aring", 229},
+		{"asymp", 8776},
+		{"atilde", 227},
+		{"auml", 228},
+		{"bdquo", 8222},
+		{"beta", 946},
+		{"brvbar", 166},
+		{"bull", 8226},
+		{"cap", 8745},
+		{"ccedil", 231},
+		{"cedil", 184},
+		{"cent", 162},
+		{"chi", 967},
+		{"circ", 710},
+		{"clubs", 9827},
+		{"cong", 8773},
+		{"copy", 169},
+		{"crarr", 8629},
+		{"cup", 8746},
+		{"curren", 164},
+		{"dArr", 8659},
+		{"dagger", 8224},
+		{"darr", 8595},
+		{"deg", 176},
+		{"delta", 948},
+		{"diams", 9830},
+		{"divide", 247},
+		{"eacute", 233},
+		{"ecirc", 234},
+		{"egrave", 232},
+		{"empty", 8709},
+		{"emsp", 8195},
+		{"ensp", 8194},
+		{"epsilon", 949},
+		{"equiv", 8801},
+		{"eta", 951},
+		{"eth", 240},
+		{"euml", 235},
+		{"euro", 8364},
+		{"exist", 8707},
+		{"fnof", 402},
+		{"forall", 8704},
+		{"frac12", 189},
+		{"frac14", 188},
+		{"frac34", 190},
+		{"frasl", 8260},
+		{"gamma", 947},
+		{"ge", 8805},
+		{"gt", 62},
+		{"hArr", 8660},
+		{"harr", 8596},
+		{"hearts", 9829},
+		{"hellip", 8230},
+		{"iacute", 237},
+		{"icirc", 238},
+		{"iexcl", 161},
+		{"igrave", 236},
+		{"image", 8465},
+		{"infin", 8734},
+		{"int", 8747},
+		{"iota", 953},
+		{"iquest", 191},
+		{"isin", 8712},
+		{"iuml", 239},
+		{"kappa", 954},
+		{"lArr", 8656},
+		{"lambda", 955},
+		{"lang", 9001},
+		{"laquo", 171},
+		{"larr", 8592},
+		{"lceil", 8968},
+		{"ldquo", 8220},
+		{"le", 8804},
+		{"lfloor", 8970},
+		{"lowast", 8727},
+		{"loz", 9674},
+		{"lrm", 8206},
+		{"lsaquo", 8249},
+		{"lsquo", 8216},
+		{"lt", 60},
+		{"macr", 175},
+		{"mdash", 8212},
+		{"micro", 181},
+		{"middot", 183},
+		{"minus", 8722},
+		{"mu", 956},
+		{"nabla", 8711},
+		{"nbsp", 160},
+		{"ndash", 8211},
+		{"ne", 8800},
+		{"ni", 8715},
+		{"not", 172},
+		{"notin", 8713},
+		{"nsub", 8836},
+		{"ntilde", 241},
+		{"nu", 957},
+		{"oacute", 243},
+		{"ocirc", 244},
+		{"oelig", 339},
+		{"ograve", 242},
+		{"oline", 8254},
+		{"omega", 969},
+		{"omicron", 959},
+		{"oplus", 8853},
+		{"or", 8744},
+		{"ordf", 170},
+		{"ordm", 186},
+		{"oslash", 248},
+		{"otilde", 245},
+		{"otimes", 8855},
+		{"ouml", 246},
+		{"para", 182},
+		{"part", 8706},
+		{"permil", 8240},
+		{"perp", 8869},
+		{"phi", 966},
+		{"pi", 960},
+		{"piv", 982},
+		{"plusmn", 177},
+		{"pound", 163},
+		{"prime", 8242},
+		{"prod", 8719},
+		{"prop", 8733},
+		{"psi", 968},
+		{"quot", 34},
+		{"rArr", 8658},
+		{"radic", 8730},
+		{"rang", 9002},
+		{"raquo", 187},
+		{"rarr", 8594},
+		{"rceil", 8969},
+		{"rdquo", 8221},
+		{"real", 8476},
+		{"reg", 174},
+		{"rfloor", 8971},
+		{"rho", 961},
+		{"rlm", 8207},
+		{"rsaquo", 8250},
+		{"rsquo", 8217},
+		{"sbquo", 8218},
+		{"scaron", 353},
+		{"sdot", 8901},
+		{"sect", 167},
+		{"shy", 173},
+		{"sigma", 963},
+		{"sigmaf", 962},
+		{"sim", 8764},
+		{"spades", 9824},
+		{"sub", 8834},
+		{"sube", 8838},
+		{"sum", 8721},
+		{"sup", 8835},
+		{"sup1", 185},
+		{"sup2", 178},
+		{"sup3", 179},
+		{"supe", 8839},
+		{"szlig", 223},
+		{"tau", 964},
+		{"there4", 8756},
+		{"theta", 952},
+		{"thetasym", 977},
+		{"thinsp", 8201},
+		{"thorn", 254},
+		{"tilde", 732},
+		{"times", 215},
+		{"trade", 8482},
+		{"uArr", 8657},
+		{"uacute", 250},
+		{"uarr", 8593},
+		{"ucirc", 251},
+		{"ugrave", 249},
+		{"uml", 168},
+		{"upsih", 978},
+		{"upsilon", 965},
+		{"uuml", 252},
+		{"weierp", 8472},
+		{"xi", 958},
+		{"yacute", 253},
+		{"yen", 165},
+		{"yuml", 255},
+		{"zeta", 950},
+		{"zwj", 8205},
+		{"zwnj", 8204},
+	};
 
 #define ENTITY_NAME_LENGTH_MAX 8
 #define NR_OF_ENTITIES 252

src/fontconfigtest.c

 {
 	gdImagePtr im;
 	int green, blue;
-	gdFTStringExtra se;	
+	gdFTStringExtra se;
 	FILE *out;
 	im = gdImageCreateTrueColor(300, 100);
 	green = gdImageColorAllocate(im, 128, 255, 128);
 	gdImageFilledRectangle(im, 0, 0, 300, 100, green);
 	blue = gdImageColorAllocate(im, 128, 128, 255);
 	/* Default: fontlist argument is a pathname to a truetype font */
-	gdImageStringFT(im, 0, blue, "arial", 
-		12, 0, 20, 20, "plain pathname default");
+	gdImageStringFT(im, 0, blue, "arial",
+	                12, 0, 20, 20, "plain pathname default");
 	/* Specifically opt for fontconfig */
 	se.flags = gdFTEX_FONTCONFIG;
-	gdImageStringFTEx(im, 0, blue, "arial:bold", 
-		12, 0, 20, 40, "fontconfig arial:bold", &se);
+	gdImageStringFTEx(im, 0, blue, "arial:bold",
+	                  12, 0, 20, 40, "fontconfig arial:bold", &se);
 	/* Change the default to fontconfig */
 	if (!gdFTUseFontConfig(1)) {
 		fprintf(stderr, "fontconfig not compiled into gd\n");
 	}
 	/* Use fontconfig by (newly set) default */
 	gdImageStringFT(im, 0, blue, "arial:bold",
-		12, 0, 20, 60, "fontconfig arial:bold default");
+	                12, 0, 20, 60, "fontconfig arial:bold default");
 	/* Explicitly use a pathname despite fontconfig default */
 	se.flags = gdFTEX_FONTPATHNAME;
-	gdImageStringFTEx(im, 0, blue, "arial", 
-		12, 0, 20, 80, "plain pathname", &se);
+	gdImageStringFTEx(im, 0, blue, "arial",
+	                  12, 0, 20, 80, "plain pathname", &se);
 #ifdef HAVE_LIBPNG
 	out = fopen("fontconfigtest.png", "wb");
 	gdImagePng(im, out);

src/fontsizetest.c

 
 void
 dosizes (gdImagePtr im, int color, char *fontfile,
-	 int x, int y, const char *string)
+         int x, int y, const char *string)
 {
-  int brect[8];
-  double curang = 0.0;
-  char *cp;
-  int cursize;
-  char buf[60];
+	int brect[8];
+	double curang = 0.0;
+	char *cp;
+	int cursize;
+	char buf[60];
 
-  for (cursize = 1; cursize <= 20; cursize++)
-    {
-      sprintf (buf, "%d: %s", cursize, string);
+	for (cursize = 1; cursize <= 20; cursize++) {
+		sprintf (buf, "%d: %s", cursize, string);
 
-      /* The case of newlines is taken care of in the gdImageStringTTF call */
+		/* The case of newlines is taken care of in the gdImageStringTTF call */
 #if defined(OLDER_GD)
-      cp =
-	gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
-			  buf);
+		cp =
+		    gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
+		                      buf);
 #else
-      cp =
-	gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
-			 buf);
+		cp =
+		    gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
+		                     buf);
 #endif
-      if (cp)
-	fprintf (stderr, "%s\n", cp);
-      y += cursize + 4;
+		if (cp)
+			fprintf (stderr, "%s\n", cp);
+		y += cursize + 4;
 
-/* render the same fontsize with antialiasing turned off */
+		/* render the same fontsize with antialiasing turned off */
 #if defined(OLDER_GD)
-      cp =
-	gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
-			  y, buf);
+		cp =
+		    gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
+		                      y, buf);
 #else
-      cp =
-	gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
-			 y, buf);
+		cp =
+		    gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
+		                     y, buf);
 #endif
-      if (cp)
-	fprintf (stderr, "%s\n", cp);
-      y += cursize + 4;
-    }
+		if (cp)
+			fprintf (stderr, "%s\n", cp);
+		y += cursize + 4;
+	}
 }
 
 void
 dotest (char *font, int w, int h, char *string, const char *filename)
 {
-  gdImagePtr im;
-  FILE *out;
-  int bg;
-  int fc;
+	gdImagePtr im;
+	FILE *out;
+	int bg;
+	int fc;
 
-  im = gdImageCreate (w, h);
-  bg = gdImageColorAllocate (im, 0, 0, 0);
+	im = gdImageCreate (w, h);
+	bg = gdImageColorAllocate (im, 0, 0, 0);
 
-  gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
+	gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
 
-  fc = gdImageColorAllocate (im, 255, 192, 192);
+	fc = gdImageColorAllocate (im, 255, 192, 192);
 
-  out = fopen (filename, "wb");
+	out = fopen (filename, "wb");
 
-  dosizes (im, fc, font, 20, 20, string);
+	dosizes (im, fc, font, 20, 20, string);
 
 #if defined(HAVE_LIBPNG)
-  gdImagePng (im, out);
+	gdImagePng (im, out);
 #elif defined(HAVE_LIBJPEG)
-  gdImageJpeg (im, out, -1);
+	gdImageJpeg (im, out, -1);
 #endif
-  fclose (out);
+	fclose (out);
 }
 
 int
 {
 
 #if defined(HAVE_LIBPNG)
-  dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.png");
-  dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png");
-  dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png");
-  dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.png");
+	dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.png");
+	dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png");
+	dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png");
+	dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.png");
 #elif defined(HAVE_LIBJPEG)
-  dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
-  dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
-  dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
-  dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
+	dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
+	dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
+	dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
+	dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
 #else
-  fprintf (stderr, "no PNG or JPEG support\n");
+	fprintf (stderr, "no PNG or JPEG support\n");
 #endif
 
-  return 0;
+	return 0;
 }

src/fontwheeltest.c

 void
 doerr (FILE * err, const char *msg)
 {
-  if (err)
-    {
-      fprintf (err, "%s\n", msg);
-      fflush (err);
-    }
+	if (err) {
+		fprintf (err, "%s\n", msg);
+		fflush (err);
+	}
 }
 
 void
 dowheel (gdImagePtr im, int color, char *fontfile, int fontsize,
-	double angle, int x, int y, int offset, char *string)
+         double angle, int x, int y, int offset, char *string)
 {
-  int brect[8];
-  FILE *err;
-  double curangrads, curang, x0, y0;
-  char *cp;
-
-  err = fopen ("err.out", "a");
-  doerr (err, "------------- New fontwheel --------------");
-  doerr (err, fontfile);
-  doerr (err, string);
-  doerr (err, "------------------------------------------");
-
-  for (curang = 0.0; curang < 360.0; curang += angle)
-    {
-      curangrads = DEGTORAD(curang);
-      x0 = x + cos (curangrads) * offset;
-      y0 = y - sin (curangrads) * offset;
-
-      /* The case of newlines is taken care of in the gdImageStringTTF call */
+	int brect[8];
+	FILE *err;
+	double curangrads, curang, x0, y0;
+	char *cp;
+
+	err = fopen ("err.out", "a");
+	doerr (err, "------------- New fontwheel --------------");
+	doerr (err, fontfile);
+	doerr (err, string);
+	doerr (err, "------------------------------------------");
+
+	for (curang = 0.0; curang < 360.0; curang += angle) {
+		curangrads = DEGTORAD(curang);
+		x0 = x + cos (curangrads) * offset;
+		y0 = y - sin (curangrads) * offset;
+
+		/* The case of newlines is taken care of in the gdImageStringTTF call */
 #if defined(OLDER_GD)
-      cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
-			  curangrads, x0, y0, string);
+		cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
+		                       curangrads, x0, y0, string);
 #else
-      cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
-			 curangrads, x0, y0, string);
+		cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
+		                      curangrads, x0, y0, string);
 #endif
-      if (cp)
-	doerr (err, cp);
+		if (cp)
+			doerr (err, cp);
 
-      gdImagePolygon (im, (gdPointPtr)brect, 4, color);
-    }
+		gdImagePolygon (im, (gdPointPtr)brect, 4, color);
+	}
 
-  fclose (err);
+	fclose (err);
 }
 
 #if 0
 void
 dolines (gdImagePtr im, int color, double incr, int x, int y, int offset,
-	 int length)
+         int length)
 {
-  double curang;
-  double angle;
-  double x0, x1, y0, y1;
-  for (curang = 0.0; curang < 360.0; curang += incr)
-    {
-      angle = curang * (2.0 * 3.14159265) / 360.0;
-      x0 = cos (angle) * offset + x;
-      x1 = cos (angle) * (offset + length) + x;
-      y0 = sin (angle) * offset + y;
-      y1 = sin (angle) * (offset + length) + y;
-      gdImageLine (im, x0, y0, x1, y1, color);
-    }
+	double curang;
+	double angle;
+	double x0, x1, y0, y1;
+	for (curang = 0.0; curang < 360.0; curang += incr) {
+		angle = curang * (2.0 * 3.14159265) / 360.0;
+		x0 = cos (angle) * offset + x;
+		x1 = cos (angle) * (offset + length) + x;
+		y0 = sin (angle) * offset + y;
+		y1 = sin (angle) * (offset + length) + y;
+		gdImageLine (im, x0, y0, x1, y1, color);
+	}
 }
 #endif
 
 void
 dotest (char *font, int size, double incr,
-	int w, int h, char *string, const char *filename)
+        int w, int h, char *string, const char *filename)
 {
-  gdImagePtr im;
-  FILE *out;
-  int bg;
-  int fc;
+	gdImagePtr im;
+	FILE *out;
+	int bg;
+	int fc;
 #if 0
-  int lc;
+	int lc;
 #endif
-  int xc = w / 2;
-  int yc = h / 2;
+	int xc = w / 2;
+	int yc = h / 2;
 
-  im = gdImageCreate (w, h);
-  bg = gdImageColorAllocate (im, 0, 0, 0);
+	im = gdImageCreate (w, h);
+	bg = gdImageColorAllocate (im, 0, 0, 0);
 
-  gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
+	gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
 
-  fc = gdImageColorAllocate (im, 255, 192, 192);
+	fc = gdImageColorAllocate (im, 255, 192, 192);
 #if 0
-  lc = gdImageColorAllocate (im, 192, 255, 255);
+	lc = gdImageColorAllocate (im, 192, 255, 255);
 #endif
 
-  out = fopen (filename, "wb");
+	out = fopen (filename, "wb");
 
-  dowheel (im, fc, font, size, incr, xc, yc, 20, string);
+	dowheel (im, fc, font, size, incr, xc, yc, 20, string);
 #if 0
-  dolines (im, lc, incr, xc, yc, 20, 120);
+	dolines (im, lc, incr, xc, yc, 20, 120);
 #endif
 
 #if defined(HAVE_LIBPNG)
-  gdImagePng (im, out);
+	gdImagePng (im, out);
 #elif defined(HAVE_LIBJPEG)
-  gdImageJpeg (im, out, -1);
+	gdImageJpeg (im, out, -1);
 #endif
 
-  fclose (out);
+	fclose (out);
 }
 
 int
 {
 
 #if defined(HAVE_LIBPNG)
-  dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
-	  "fontwheeltest1.png");
-  dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
-	  "fontwheeltest2.png");
-  dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
-	  "fontwheeltest3.png");
-  dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
-	  "fontwheeltest4.png");
+	dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
+	        "fontwheeltest1.png");
+	dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
+	        "fontwheeltest2.png");
+	dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
+	        "fontwheeltest3.png");
+	dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
+	        "fontwheeltest4.png");
 #elif defined(HAVE_LIBJPEG)
-  dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
-	  "fontwheeltest1.jpeg");
-  dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
-	  "fontwheeltest2.jpeg");
-  dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
-	  "fontwheeltest3.jpeg");
-  dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
-	  "fontwheeltest4.jpeg");
+	dotest ("times", 16, 20.0, 400, 400, "Hello, there!",
+	        "fontwheeltest1.jpeg");
+	dotest ("times", 16, 30.0, 400, 400, "Hello, there!",
+	        "fontwheeltest2.jpeg");
+	dotest ("arial", 16, 45.0, 400, 400, "Hello, there!",
+	        "fontwheeltest3.jpeg");
+	dotest ("arial", 16, 90.0, 400, 400, "Hello\nthere!",
+	        "fontwheeltest4.jpeg");
 #else
-  fprintf (stderr, "no PNG or JPEG support\n");
+	fprintf (stderr, "no PNG or JPEG support\n");
 #endif
 
-  return 0;
+	return 0;
 }
 #else /*CHARSET_EBCDIC */
 #define ASC(ch) gd_toascii[(unsigned char)ch]
 static const unsigned char gd_toascii[256] = {
-/*00 */ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
-  0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,	/*................ */
-/*10 */ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
-  0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f,	/*................ */
-/*20 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
-  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,	/*................ */
-/*30 */ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
-  0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,	/*................ */
-/*40 */ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
-  0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,	/* .........`.<(+| */
-/*50 */ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
-  0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f,	/*&.........!$*);. */
-/*60 */ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
-  0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
-/*-/........^,%_>?*/
-/*70 */ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
-  0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,	/*..........:#@'=" */
-/*80 */ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-  0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,	/*.abcdefghi...... */
-/*90 */ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
-  0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,	/*.jklmnopqr...... */
-/*a0 */ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-  0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,	/*..stuvwxyz...... */
-/*b0 */ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
-  0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7,	/*...........[\].. */
-/*c0 */ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-  0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,	/*.ABCDEFGHI...... */
-/*d0 */ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
-  0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff,	/*.JKLMNOPQR...... */
-/*e0 */ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-  0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,	/*..STUVWXYZ...... */
-/*f0 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-  0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e	/*0123456789.{.}.~ */
+	/*00 */ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
+	0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,	/*................ */
+	/*10 */ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
+	0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f,	/*................ */
+	/*20 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
+	0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,	/*................ */
+	/*30 */ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+	0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,	/*................ */
+	/*40 */ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+	0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,	/* .........`.<(+| */
+	/*50 */ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+	0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f,	/*&.........!$*);. */
+	/*60 */ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+	0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+	/*-/........^,%_>?*/
+	/*70 */ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+	0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,	/*..........:#@'=" */
+	/*80 */ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+	0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,	/*.abcdefghi...... */