VirtualBox

Changeset 84054 in vbox for trunk/src/VBox/Runtime/win


Ignore:
Timestamp:
Apr 28, 2020 4:05:00 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137633
Message:

IPRT,++: Apply bldprog-strtab.h and friends to the IPRT status message database (errmsg.cpp) to reduce size. The interface (RTErrMsg*) has been reworked as we no longer have C-strings in the database, but 'compressed' string w/o zero terminators. bugref:9726

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/win/errmsgwin-sorter.cpp

    r83984 r84054  
    3939
    4040
     41#define ERRMSG_WITH_STRTAB
     42#ifdef ERRMSG_WITH_STRTAB
     43/*
     44 * Include the string table code.
     45 */
     46# define BLDPROG_STRTAB_MAX_STRLEN           512
     47# define BLDPROG_STRTAB_WITH_COMPRESSION
     48# define BLDPROG_STRTAB_PURE_ASCII
     49# define BLDPROG_STRTAB_WITH_CAMEL_WORDS
     50# include <iprt/bldprog-strtab-template.cpp.h>
     51#endif
     52
     53
    4154/*********************************************************************************************************************************
    4255*   Defined Constants And Macros                                                                                                 *
     
    5770*   Global Variables                                                                                                             *
    5871*********************************************************************************************************************************/
     72static const char *g_pszProgName = "errmsgwin-sorter";
    5973static RTWINERRMSG  g_aStatusMsgs[] =
    6074{
     
    6781    { "Success.", "ERROR_SUCCESS", 0 },
    6882};
     83
     84
     85static RTEXITCODE error(const char *pszFormat,  ...)
     86{
     87    va_list va;
     88    va_start(va, pszFormat);
     89    fprintf(stderr, "%s: error: ", g_pszProgName);
     90    vfprintf(stderr, pszFormat, va);
     91    va_end(va);
     92    return RTEXITCODE_FAILURE;
     93}
    6994
    7095
     
    156181    if (pOut)
    157182    {
     183#ifdef ERRMSG_WITH_STRTAB
     184        /*
     185         * String table fun.
     186         */
     187        static BLDPROGSTRING s_aStrings[RT_ELEMENTS(g_aStatusMsgs) * 2];
     188        size_t               iString = 0;
     189        BLDPROGSTRTAB        StrTab;
     190        if (!BldProgStrTab_Init(&StrTab, RT_ELEMENTS(s_aStrings)))
     191            return error("Out of memory!\n");
     192#endif
     193
    158194        /*
    159195         * Print the table.
     
    184220            iPrev = pMsg->iCode;
    185221
     222#ifdef ERRMSG_WITH_STRTAB
     223# if 1
     224            s_aStrings[iString].pszString = strdup(pMsg->pszDefine);
     225            BldProgStrTab_AddString(&StrTab, &s_aStrings[iString]);
     226            iString++;
     227# endif
     228# if 0
     229            s_aStrings[iString].pszString = strdup(pMsg->pszMsgFull);
     230            BldProgStrTab_AddString(&StrTab, &s_aStrings[iString]);
     231            iString++;
     232# endif
     233#endif
     234
    186235            /* Produce the output: */
    187236            fprintf(pOut, "/*%#010lx:*/ ENTRY(\"%s\", \"%s\", %ld),\n", (unsigned long)pMsg->iCode,
     
    197246            rcExit = RTEXITCODE_FAILURE;
    198247        }
     248
     249#ifdef ERRMSG_WITH_STRTAB
     250        /*
     251         * More string table fun.
     252         */
     253        if (!BldProgStrTab_CompileIt(&StrTab, true))
     254            return error("BldProgStrTab_CompileIt failed!\n");
     255#endif
    199256    }
    200257    else
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette