changes from H.G. Muller; version 4.3.13
[xboard.git] / winboard / wgamelist.c
index 5fa191c..e1bf978 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * wgamelist.c -- Game list window for WinBoard\r
- * $Id: wgamelist.c,v 2.1 2003/10/27 19:21:02 mann Exp $
+ * $Id: wgamelist.c,v 2.1 2003/10/27 19:21:02 mann Exp $\r
  *\r
  * Copyright 1995 Free Software Foundation, Inc.\r
  *\r
@@ -36,8 +36,8 @@
 #include "frontend.h"\r
 #include "backend.h"\r
 \r
-#include "wsnap.h"
-
+#include "wsnap.h"\r
+\r
 /* Module globals */\r
 HWND gameListDialog = NULL;\r
 BOOLEAN gameListUp = FALSE;\r
@@ -49,185 +49,185 @@ int gameListX, gameListY, gameListW, gameListH;
 extern HINSTANCE hInst;\r
 extern HWND hwndMain;\r
 \r
-struct GameListStats
-{
-    int white_wins;
-    int black_wins;
-    int drawn;
-    int unfinished;
-};
-
-/* [AS] Wildcard pattern matching */
-static BOOL HasPattern( const char * text, const char * pattern )
-{
-    while( *pattern != '\0' ) {
-        if( *pattern == '*' ) {
-            while( *pattern == '*' ) {
-                pattern++;
-            }
-
-            if( *pattern == '\0' ) {
-                return TRUE;
-            }
-
-            while( *text != '\0' ) {
-                if( HasPattern( text, pattern ) ) {
-                    return TRUE;
-                }
-                text++;
-            }
-        }
-        else if( (*pattern == *text) || ((*pattern == '?') && (*text != '\0')) ) {
-            pattern++;
-            text++;
-            continue;
-        }
-
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-static BOOL SearchPattern( const char * text, const char * pattern )
-{
-    BOOL result = TRUE;
-
-    if( pattern != NULL && *pattern != '\0' ) {
-        if( *pattern == '*' ) {
-            result = HasPattern( text, pattern );
-        }
-        else {
-            result = FALSE;
-
-            while( *text != '\0' ) {
-                if( HasPattern( text, pattern ) ) {
-                    result = TRUE;
-                    break;
-                }
-                text++;
-            }
-        }
-    }
-
-    return result;
-}
-
-/* [AS] Setup the game list according to the specified filter */
-static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats )
-{
-    ListGame * lg = (ListGame *) gameList.head;
-    int nItem;
-    BOOL hasFilter = FALSE;
-    int count = 0;
-    struct GameListStats dummy;
-
-    /* Initialize stats (use a dummy variable if caller not interested in them) */
-    if( stats == NULL ) {
-        stats = &dummy;
-    }
-
-    stats->white_wins = 0;
-    stats->black_wins = 0;
-    stats->drawn = 0;
-    stats->unfinished = 0;
-
-    if( boReset ) {
-        SendDlgItemMessage(hDlg, OPT_GameListText, LB_RESETCONTENT, 0, 0);
-    }
-
-    if( pszFilter != NULL ) {
-        if( strlen( pszFilter ) > 0 ) {
-            hasFilter = TRUE;
-        }
-    }
-
-    for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
-        char * st = GameListLine(lg->number, &lg->gameInfo);
-        BOOL skip = FALSE;
-
-        if( hasFilter ) {
-            if( ! SearchPattern( st, pszFilter ) ) {
-                skip = TRUE;
-            }
-        }
-
-        if( ! skip ) {
-            SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st);
-            count++;
-
-            /* Update stats */
-            if( lg->gameInfo.result == WhiteWins )
-                stats->white_wins++;
-            else if( lg->gameInfo.result == BlackWins )
-                stats->black_wins++;
-            else if( lg->gameInfo.result == GameIsDrawn )
-                stats->drawn++;
-            else
-                stats->unfinished++;
-        }
-
-        free(st);
-        lg = (ListGame *) lg->node.succ;
-    }
-
-    SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0);
-
-    return count;
-}
-
-/* [AS] Show number of visible (filtered) games and total on window caption */
-static int GameListUpdateTitle( HWND hDlg, char * pszTitle, int item_count, int item_total, struct GameListStats * stats )
-{
-    char buf[256];
-
-    sprintf( buf, "%s - %d/%d games", pszTitle, item_count, item_total );
-
-    if( stats != 0 ) {
-        sprintf( buf+strlen(buf), " (%d-%d-%d)", stats->white_wins, stats->black_wins, stats->drawn );
-    }
-
-    SetWindowText( hDlg, buf );
-
-    return 0;
-}
-
-#define MAX_FILTER_LENGTH   128
+struct GameListStats\r
+{\r
+    int white_wins;\r
+    int black_wins;\r
+    int drawn;\r
+    int unfinished;\r
+};\r
+\r
+/* [AS] Wildcard pattern matching */\r
+static BOOL HasPattern( const char * text, const char * pattern )\r
+{\r
+    while( *pattern != '\0' ) {\r
+        if( *pattern == '*' ) {\r
+            while( *pattern == '*' ) {\r
+                pattern++;\r
+            }\r
+\r
+            if( *pattern == '\0' ) {\r
+                return TRUE;\r
+            }\r
+\r
+            while( *text != '\0' ) {\r
+                if( HasPattern( text, pattern ) ) {\r
+                    return TRUE;\r
+                }\r
+                text++;\r
+            }\r
+        }\r
+        else if( (*pattern == *text) || ((*pattern == '?') && (*text != '\0')) ) {\r
+            pattern++;\r
+            text++;\r
+            continue;\r
+        }\r
+\r
+        return FALSE;\r
+    }\r
+\r
+    return TRUE;\r
+}\r
+\r
+static BOOL SearchPattern( const char * text, const char * pattern )\r
+{\r
+    BOOL result = TRUE;\r
+\r
+    if( pattern != NULL && *pattern != '\0' ) {\r
+        if( *pattern == '*' ) {\r
+            result = HasPattern( text, pattern );\r
+        }\r
+        else {\r
+            result = FALSE;\r
+\r
+            while( *text != '\0' ) {\r
+                if( HasPattern( text, pattern ) ) {\r
+                    result = TRUE;\r
+                    break;\r
+                }\r
+                text++;\r
+            }\r
+        }\r
+    }\r
+\r
+    return result;\r
+}\r
+\r
+/* [AS] Setup the game list according to the specified filter */\r
+static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats )\r
+{\r
+    ListGame * lg = (ListGame *) gameList.head;\r
+    int nItem;\r
+    BOOL hasFilter = FALSE;\r
+    int count = 0;\r
+    struct GameListStats dummy;\r
+\r
+    /* Initialize stats (use a dummy variable if caller not interested in them) */\r
+    if( stats == NULL ) { \r
+        stats = &dummy;\r
+    }\r
+\r
+    stats->white_wins = 0;\r
+    stats->black_wins = 0;\r
+    stats->drawn = 0;\r
+    stats->unfinished = 0;\r
+\r
+    if( boReset ) {\r
+        SendDlgItemMessage(hDlg, OPT_GameListText, LB_RESETCONTENT, 0, 0);\r
+    }\r
+\r
+    if( pszFilter != NULL ) {\r
+        if( strlen( pszFilter ) > 0 ) {\r
+            hasFilter = TRUE;\r
+        }\r
+    }\r
+\r
+    for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){\r
+        char * st = GameListLine(lg->number, &lg->gameInfo);\r
+        BOOL skip = FALSE;\r
+\r
+        if( hasFilter ) {\r
+            if( ! SearchPattern( st, pszFilter ) ) {\r
+                skip = TRUE;\r
+            }\r
+        }\r
+\r
+        if( ! skip ) {\r
+            SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st);\r
+            count++;\r
+\r
+            /* Update stats */\r
+            if( lg->gameInfo.result == WhiteWins )\r
+                stats->white_wins++;\r
+            else if( lg->gameInfo.result == BlackWins )\r
+                stats->black_wins++;\r
+            else if( lg->gameInfo.result == GameIsDrawn )\r
+                stats->drawn++;\r
+            else\r
+                stats->unfinished++;\r
+        }\r
+\r
+        free(st);\r
+        lg = (ListGame *) lg->node.succ;\r
+    }\r
+\r
+    SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0);\r
+\r
+    return count;\r
+}\r
+\r
+/* [AS] Show number of visible (filtered) games and total on window caption */\r
+static int GameListUpdateTitle( HWND hDlg, char * pszTitle, int item_count, int item_total, struct GameListStats * stats )\r
+{\r
+    char buf[256];\r
+\r
+    sprintf( buf, "%s - %d/%d games", pszTitle, item_count, item_total );\r
+\r
+    if( stats != 0 ) {\r
+        sprintf( buf+strlen(buf), " (%d-%d-%d)", stats->white_wins, stats->black_wins, stats->drawn );\r
+    }\r
+\r
+    SetWindowText( hDlg, buf );\r
+\r
+    return 0;\r
+}\r
+\r
+#define MAX_FILTER_LENGTH   128\r
 \r
 LRESULT CALLBACK\r
 GameListDialog(HWND hDlg, UINT message,        WPARAM wParam, LPARAM lParam)\r
 {\r
-  static char szDlgTitle[64];
+  static char szDlgTitle[64];\r
   static HANDLE hwndText;\r
   int nItem;\r
   RECT rect;\r
   static int sizeX, sizeY;\r
   int newSizeX, newSizeY, flags;\r
   MINMAXINFO *mmi;\r
-  static BOOL filterHasFocus = FALSE;
-  int count;
-  struct GameListStats stats;
-  static SnapData sd;
+  static BOOL filterHasFocus = FALSE;\r
+  int count;\r
+  struct GameListStats stats;\r
+  static SnapData sd;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: \r
-    GetWindowText( hDlg, szDlgTitle, sizeof(szDlgTitle) );
-    szDlgTitle[ sizeof(szDlgTitle)-1 ] = '\0';
-
+    GetWindowText( hDlg, szDlgTitle, sizeof(szDlgTitle) );\r
+    szDlgTitle[ sizeof(szDlgTitle)-1 ] = '\0';\r
+\r
     if (gameListDialog) {\r
       SendDlgItemMessage(hDlg, OPT_GameListText, LB_RESETCONTENT, 0, 0);\r
     }\r
-
+\r
     /* Initialize the dialog items */\r
     hwndText = GetDlgItem(hDlg, OPT_TagsText);\r
-
-    count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats );
-
-    SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" );
-    SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 );
-
-    filterHasFocus = FALSE;
-
+\r
+    count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats );\r
+\r
+    SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" );\r
+    SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 );\r
+\r
+    filterHasFocus = FALSE;\r
+\r
     /* Size and position the dialog */\r
     if (!gameListDialog) {\r
       gameListDialog = hDlg;\r
@@ -257,8 +257,8 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
        sizeX = newSizeX;\r
        sizeY = newSizeY;\r
       }\r
-
-      GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats );
+\r
+      GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats );\r
     }\r
     return FALSE;\r
     \r
@@ -271,18 +271,18 @@ GameListDialog(HWND hDlg, UINT message,   WPARAM wParam, LPARAM lParam)
     sizeY = newSizeY;\r
     break;\r
 \r
-  case WM_ENTERSIZEMOVE:
-    return OnEnterSizeMove( &sd, hDlg, wParam, lParam );
-
-  case WM_SIZING:
-    return OnSizing( &sd, hDlg, wParam, lParam );
-
-  case WM_MOVING:
-    return OnMoving( &sd, hDlg, wParam, lParam );
-
-  case WM_EXITSIZEMOVE:
-    return OnExitSizeMove( &sd, hDlg, wParam, lParam );
-
+  case WM_ENTERSIZEMOVE:\r
+    return OnEnterSizeMove( &sd, hDlg, wParam, lParam );\r
+\r
+  case WM_SIZING:\r
+    return OnSizing( &sd, hDlg, wParam, lParam );\r
+\r
+  case WM_MOVING:\r
+    return OnMoving( &sd, hDlg, wParam, lParam );\r
+\r
+  case WM_EXITSIZEMOVE:\r
+    return OnExitSizeMove( &sd, hDlg, wParam, lParam );\r
+  \r
   case WM_GETMINMAXINFO:\r
     /* Prevent resizing window too small */\r
     mmi = (MINMAXINFO *) lParam;\r
@@ -291,27 +291,27 @@ GameListDialog(HWND hDlg, UINT message,   WPARAM wParam, LPARAM lParam)
     break;\r
 \r
   case WM_COMMAND:\r
-      /*
-        [AS]
-        If <Enter> is pressed while editing the filter, it's better to apply
-        the filter rather than selecting the current game.
-      */
-      if( LOWORD(wParam) == IDC_GameListFilter ) {
-          switch( HIWORD(wParam) ) {
-          case EN_SETFOCUS:
-              filterHasFocus = TRUE;
-              break;
-          case EN_KILLFOCUS:
-              filterHasFocus = FALSE;
-              break;
-          }
-      }
-
-      if( filterHasFocus && (LOWORD(wParam) == IDOK) ) {
-          wParam = IDC_GameListDoFilter;
-      }
-      /* [AS] End command replacement */
-
+      /* \r
+        [AS]\r
+        If <Enter> is pressed while editing the filter, it's better to apply\r
+        the filter rather than selecting the current game.\r
+      */\r
+      if( LOWORD(wParam) == IDC_GameListFilter ) {\r
+          switch( HIWORD(wParam) ) {\r
+          case EN_SETFOCUS:\r
+              filterHasFocus = TRUE;\r
+              break;\r
+          case EN_KILLFOCUS:\r
+              filterHasFocus = FALSE;\r
+              break;\r
+          }\r
+      }\r
+\r
+      if( filterHasFocus && (LOWORD(wParam) == IDOK) ) {\r
+          wParam = IDC_GameListDoFilter;\r
+      }\r
+      /* [AS] End command replacement */\r
+\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
     case OPT_GameListLoad:\r
@@ -327,8 +327,8 @@ GameListDialog(HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
       nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0);\r
       nItem++;\r
       if (nItem >= ((ListGame *) gameList.tailPred)->number) {\r
-        /* [AS] Removed error message */
-       /* DisplayError("Can't go forward any further", 0); */
+        /* [AS] Removed error message */\r
+       /* DisplayError("Can't go forward any further", 0); */\r
        return TRUE;\r
       }\r
       SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0);\r
@@ -338,27 +338,27 @@ GameListDialog(HWND hDlg, UINT message,   WPARAM wParam, LPARAM lParam)
       nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0);\r
       nItem--;\r
       if (nItem < 0) {\r
-        /* [AS] Removed error message, added return */
-       /* DisplayError("Can't back up any further", 0); */
-        return TRUE;
+        /* [AS] Removed error message, added return */\r
+       /* DisplayError("Can't back up any further", 0); */\r
+        return TRUE;\r
       }\r
       SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0);\r
       break; /* load the game*/\r
-      \r
-    /* [AS] */
-    case IDC_GameListDoFilter:
-        {
-            char filter[MAX_FILTER_LENGTH+1];
-
-            if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) {
-                filter[ sizeof(filter)-1 ] = '\0';
-                count = GameListToListBox( hDlg, TRUE, filter, &stats );
-                GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats );
-            }
-        }
-        return FALSE;
-        break;
-
+\r
+    /* [AS] */\r
+    case IDC_GameListDoFilter:\r
+        {\r
+            char filter[MAX_FILTER_LENGTH+1];\r
+            \r
+            if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) {\r
+                filter[ sizeof(filter)-1 ] = '\0';\r
+                count = GameListToListBox( hDlg, TRUE, filter, &stats );\r
+                GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats );\r
+            }\r
+        }\r
+        return FALSE;\r
+        break;\r
+\r
     case IDCANCEL:\r
     case OPT_GameListClose:\r
       GameListPopDown();\r
@@ -374,47 +374,47 @@ GameListDialog(HWND hDlg, UINT message,   WPARAM wParam, LPARAM lParam)
        return FALSE;\r
       }\r
       break;\r
-      \r
+\r
     default:\r
       return FALSE;\r
     }\r
-
+\r
     /* Load the game */\r
-    {
-        /* [AS] Get index from the item itself, because filtering makes original order unuseable. */
-        int index = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0);
-        char * text;
-        LRESULT res;
-
-        if( index < 0 ) {
-            return TRUE;
-        }
-
-        res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXTLEN, index, 0 );
-
-        if( res == LB_ERR ) {
-            return TRUE;
-        }
-
-        text = (char *) malloc( res+1 );
-
-        res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXT, index, (LPARAM)text );
-
-        index = atoi( text );
-
-        nItem = index - 1;
-
-        free( text );
-        /* [AS] End: nItem has been "patched" now! */
-
-    if (cmailMsgLoaded) {\r
-      CmailLoadGame(gameFile, nItem + 1, gameFileName, TRUE);\r
-        }
-        else {
-      LoadGame(gameFile, nItem + 1, gameFileName, TRUE);\r
+    {\r
+        /* [AS] Get index from the item itself, because filtering makes original order unuseable. */\r
+        int index = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0);\r
+        char * text;\r
+        LRESULT res;\r
+\r
+        if( index < 0 ) {\r
+            return TRUE;\r
+        }\r
+\r
+        res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXTLEN, index, 0 );\r
+\r
+        if( res == LB_ERR ) {\r
+            return TRUE;\r
+        }\r
+\r
+        text = (char *) malloc( res+1 );\r
+\r
+        res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXT, index, (LPARAM)text );\r
+\r
+        index = atoi( text );\r
+\r
+        nItem = index - 1;\r
+\r
+        free( text );\r
+        /* [AS] End: nItem has been "patched" now! */\r
+\r
+        if (cmailMsgLoaded) {\r
+            CmailLoadGame(gameFile, nItem + 1, gameFileName, TRUE);\r
+        }\r
+        else {\r
+            LoadGame(gameFile, nItem + 1, gameFileName, TRUE);\r
+        }\r
     }\r
-    }
-
+\r
     return TRUE;\r
 \r
   default:\r
@@ -483,56 +483,56 @@ VOID ShowGameListProc()
     }\r
   }\r
 }\r
-
-HGLOBAL ExportGameListAsText()
-{
-    HGLOBAL result = NULL;
-    LPVOID lpMem = NULL;
-    ListGame * lg = (ListGame *) gameList.head;
-    int nItem;
-    DWORD dwLen = 0;
-
-    if( ! gameFileName || ((ListGame *) gameList.tailPred)->number <= 0 ) {
-        DisplayError("Game list not loaded or empty", 0);
-        return NULL;
-    }
-
-    /* Get list size */
-    for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
-        char * st = GameListLineFull(lg->number, &lg->gameInfo);
-
-        dwLen += strlen(st) + 2; /* Add extra characters for "\r\n" */
-
-        free(st);
-        lg = (ListGame *) lg->node.succ;
-    }
-
-    /* Allocate memory for the list */
-    result = GlobalAlloc(GHND, dwLen+1 );
-
-    if( result != NULL ) {
-        lpMem = GlobalLock(result);
-    }
-
-    /* Copy the list into the global memory block */
-    if( lpMem != NULL ) {
-        char * dst = (char *) lpMem;
-        size_t len;
-
-        lg = (ListGame *) gameList.head;
-
-        for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
-            char * st = GameListLineFull(lg->number, &lg->gameInfo);
-
-            len = sprintf( dst, "%s\r\n", st );
-            dst += len;
-
-            free(st);
-            lg = (ListGame *) lg->node.succ;
-        }
-
-        GlobalUnlock( result );
-    }
-
-    return result;
-}
+\r
+HGLOBAL ExportGameListAsText()\r
+{\r
+    HGLOBAL result = NULL;\r
+    LPVOID lpMem = NULL;\r
+    ListGame * lg = (ListGame *) gameList.head;\r
+    int nItem;\r
+    DWORD dwLen = 0;\r
+\r
+    if( ! gameFileName || ((ListGame *) gameList.tailPred)->number <= 0 ) {\r
+        DisplayError("Game list not loaded or empty", 0);\r
+        return NULL;\r
+    }\r
+\r
+    /* Get list size */\r
+    for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){\r
+        char * st = GameListLineFull(lg->number, &lg->gameInfo);\r
+\r
+        dwLen += strlen(st) + 2; /* Add extra characters for "\r\n" */\r
+\r
+        free(st);\r
+        lg = (ListGame *) lg->node.succ;\r
+    }\r
+\r
+    /* Allocate memory for the list */\r
+    result = GlobalAlloc(GHND, dwLen+1 );\r
+\r
+    if( result != NULL ) {\r
+        lpMem = GlobalLock(result);\r
+    }\r
+\r
+    /* Copy the list into the global memory block */\r
+    if( lpMem != NULL ) {\r
+        char * dst = (char *) lpMem;\r
+        size_t len;\r
+\r
+        lg = (ListGame *) gameList.head;\r
+\r
+        for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){\r
+            char * st = GameListLineFull(lg->number, &lg->gameInfo);\r
+\r
+            len = sprintf( dst, "%s\r\n", st );\r
+            dst += len;\r
+\r
+            free(st);\r
+            lg = (ListGame *) lg->node.succ;\r
+        }\r
+\r
+        GlobalUnlock( result );\r
+    }\r
+\r
+    return result;\r
+}\r