Changeset 997


Ignore:
Timestamp:
Aug 17, 2011, 4:45:20 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: gnumake/os2: Quote paths with trailing separators.

This is to avoid interpreting the trailing back slash as a line break.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qmake/generators/os2/gnumake.cpp

    r996 r997  
    7373    QString ret = path;
    7474    // we assume that make variables contain paths already properly escaped
    75     if (!path.contains(QRegExp("\\$\\(([^$)]+)\\)"))) {
     75    if (!ret.isEmpty() && !ret.contains(QRegExp("\\$\\(([^$)]+)\\)"))) {
     76        ret = unescapeFilePath(ret);
    7677        if (!isDosLikeShell()) {
    77             ret.remove('\"');
    7878            ret.replace('\\', '/');
    7979            ret.replace(' ', "\\ ");
    8080        } else {
    81             ret.replace(QRegExp("\""), "");
    8281            ret.replace('/', '\\');
    83             if (ret.contains(QRegExp("[ +&;%]")))
     82            // Note: also quote paths ending with the backslash to avoid
     83            // interpreting it as a linebreak
     84            if (ret.contains(QRegExp("[ +&;%]")) || ret.endsWith('\\'))
    8485                ret = quote + ret + quote;
    8586        }
     
    9697    // it at runtime.
    9798    QString ret = path;
    98     bool matched = false;
    99     if (path.contains("$("))
    100         ret = escapeFileVars(path, &matched);
    101     if (!matched) {
    102         // didn't find variable references, do plain escaping
    103         ret.remove('\"');
    104         ret.replace(' ', "\\ ");
    105         // and we still want to normalize slashes as this is what we do in
    106         // other places (e.g. .cpp targets); this function will do it for
    107         // QMAKE_EXTRA_TARGETS as well
    108         if (!isDosLikeShell())
    109             ret.replace('\\', '/');
    110         else
    111             ret.replace('/', '\\');
     99    if (!ret.isEmpty()) {
     100        bool matched = false;
     101        if (path.contains("$("))
     102            ret = escapeFileVars(path, &matched);
     103        if (!matched) {
     104            // didn't find variable references, do plain escaping
     105            ret = unescapeFilePath(ret);
     106            ret.replace(' ', "\\ ");
     107            // and we still want to normalize slashes as this is what we do in
     108            // other places (e.g. .cpp targets); this function will do it for
     109            // QMAKE_EXTRA_TARGETS as well
     110            if (!isDosLikeShell())
     111                ret.replace('\\', '/');
     112            else
     113                ret.replace('/', '\\');
     114        }
    112115    }
    113116    return ret;
Note: See TracChangeset for help on using the changeset viewer.