PDA

View Full Version : What's the charactor ‘^' mean in the qmake file?



Michael_BJFU
3rd October 2012, 04:28
Recently i read the source of qt creator. However I found a lot of doubtable codes. Have look at the codes below:

defineReplace(cleanPath) {
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
return($$join(out, /, $$pfx))
}
What do the four backslashs mean? and also the '|g', '^' ? I can't find anything useful in the document.

ChrisW67
3rd October 2012, 05:50
Four backslashes represents two literal backslashes. The backslash character escapes the special meaning of the character following it, just like you see in C++ code where you wanted two literal backslashes.

The syntax on line 2 is documented on this page. The regular expression syntax is Perl-esque. The carets are part of a regular expression, meaning "match at start" and the g modifier means find all matches in the target value. That particular line is replacing backslashes with forward slashes.

Line 3 is checking if the path begins with a '/' followed by any number of other characters and setting a variable accordingly.

Michael_BJFU
3rd October 2012, 13:39
There is a function in qmake file in the source of qt creator called re_escape(), what does it mean ?Do I need to learn something about Perl in order to learn more about Qt?

amleto
3rd October 2012, 19:14
google is your friend...
http://www.qtcentre.org/wiki/index.php?title=Undocumented_qmake