VirtualBox

Changeset 62919 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 3, 2016 2:16:14 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
109521
Message:

Please use 'static const' on data that is constant, don't make the compiler recreated on the stack for each call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r62468 r62919  
    14061406void sanitiseMachineFilename(Utf8Str &strName)
    14071407{
    1408     /** Set of characters which should be safe for use in filenames: some basic
     1408    /* Set of characters which should be safe for use in filenames: some basic
    14091409     * ASCII, Unicode from Latin-1 alphabetic to the end of Hangul.  We try to
    14101410     * skip anything that could count as a control character in Windows or
    14111411     * *nix, or be otherwise difficult for shells to handle (I would have
    14121412     * preferred to remove the space and brackets too).  We also remove all
    1413      * characters which need UTF-16 surrogate pairs for Windows's benefit. */
    1414     RTUNICP aCpSet[] =
    1415         { ' ', ' ', '(', ')', '-', '.', '0', '9', 'A', 'Z', 'a', 'z', '_', '_',
    1416           0xa0, 0xd7af, '\0' };
     1413     * characters which need UTF-16 surrogate pairs for Windows's benefit.
     1414     */
     1415    static RTUNICP const s_uszValidRangePairs[] =
     1416    {
     1417        ' ', ' ',
     1418        '(', ')',
     1419        '-', '.',
     1420        '0', '9',
     1421        'A', 'Z',
     1422        'a', 'z',
     1423        '_', '_',
     1424        0xa0, 0xd7af,
     1425        '\0'
     1426    };
     1427
    14171428    char *pszName = strName.mutableRaw();
    1418     ssize_t cReplacements = RTStrPurgeComplementSet(pszName, aCpSet, '_');
     1429    ssize_t cReplacements = RTStrPurgeComplementSet(pszName, s_uszValidRangePairs, '_');
    14191430    Assert(cReplacements >= 0);
    14201431    NOREF(cReplacements);
     1432
    14211433    /* No leading dot or dash. */
    14221434    if (pszName[0] == '.' || pszName[0] == '-')
    14231435        pszName[0] = '_';
     1436
    14241437    /* No trailing dot. */
    14251438    if (pszName[strName.length() - 1] == '.')
    14261439        pszName[strName.length() - 1] = '_';
     1440
    14271441    /* Mangle leading and trailing spaces. */
    14281442    for (size_t i = 0; pszName[i] == ' '; ++i)
Note: See TracChangeset for help on using the changeset viewer.

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