Mercurial > octave
comparison src/mkoctfile.in.cc @ 15299:8bd5c490b787
Fix mex compilation with subdirs on Windows platforms (bug #37122)
* mkoctfile.in.cc (basename): Fix basename routine which was returning basedir,
not basename.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 05 Sep 2012 08:14:37 -0700 |
parents | 648dabbb4c6b |
children | c398dde4d409 |
comparison
equal
deleted
inserted
replaced
15298:704ab1b4c369 | 15299:8bd5c490b787 |
---|---|
23 #if defined (HAVE_CONFIG_H) | 23 #if defined (HAVE_CONFIG_H) |
24 #include <config.h> | 24 #include <config.h> |
25 #endif | 25 #endif |
26 | 26 |
27 #include <string> | 27 #include <string> |
28 #include <cstring> | |
28 #include <map> | 29 #include <map> |
29 #include <list> | 30 #include <list> |
30 #include <algorithm> | 31 #include <algorithm> |
31 #include <iostream> | 32 #include <iostream> |
32 #include <fstream> | 33 #include <fstream> |
317 " EXEEXT RDYNAMIC_FLAG\n" | 318 " EXEEXT RDYNAMIC_FLAG\n" |
318 " F77 READLINE_LIBS\n" | 319 " F77 READLINE_LIBS\n" |
319 " F77_INTEGER_8_FLAG SED\n" | 320 " F77_INTEGER_8_FLAG SED\n" |
320 " FFLAGS XTRA_CFLAGS\n" | 321 " FFLAGS XTRA_CFLAGS\n" |
321 " FFTW3_LDFLAGS XTRA_CXXFLAGS\n" | 322 " FFTW3_LDFLAGS XTRA_CXXFLAGS\n" |
322 " FFTW3_LIBS | 323 " FFTW3_LIBS\n" |
323 " FFTW3F_LDFLAGS\n" | 324 " FFTW3F_LDFLAGS\n" |
324 " FFTW3F_LIBS\n" | 325 " FFTW3F_LIBS\n" |
325 "\n" | 326 "\n" |
326 " --link-stand-alone Link a stand-alone executable file.\n" | 327 " --link-stand-alone Link a stand-alone executable file.\n" |
327 "\n" | 328 "\n" |
350 "\n"; | 351 "\n"; |
351 | 352 |
352 static string | 353 static string |
353 basename (const string& s, bool strip_path = false) | 354 basename (const string& s, bool strip_path = false) |
354 { | 355 { |
356 string retval; | |
355 size_t pos = s.rfind ('.'); | 357 size_t pos = s.rfind ('.'); |
356 string retval; | |
357 | 358 |
358 if (pos == string::npos) | 359 if (pos == string::npos) |
359 retval = s; | 360 retval = s; |
360 else | 361 else |
361 retval = s.substr (0, pos); | 362 retval = s.substr (0, pos); |
363 | |
362 if (strip_path) | 364 if (strip_path) |
363 { | 365 { |
364 size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\'); | 366 size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\'); |
365 pos = (p1 != string::npos && p2 != string::npos | 367 pos = (p1 != string::npos && p2 != string::npos |
366 ? max (p1, p2) : (p2 != string::npos ? p2 : p1)); | 368 ? max (p1, p2) : (p2 != string::npos ? p2 : p1)); |
367 if (pos != string::npos) | 369 if (pos != string::npos) |
368 retval = retval.substr (0, pos); | 370 retval = retval.substr (++pos, string::npos); |
369 } | 371 } |
372 | |
370 return retval; | 373 return retval; |
371 } | 374 } |
372 | 375 |
373 inline bool | 376 inline bool |
374 starts_with (const string& s, const string& prefix) | 377 starts_with (const string& s, const string& prefix) |