Bo,

while resolving some merge conflicts (I am playing with kde autoopen) I 
noticed that you had some whitespace issues in the patch (param=value vs. 
param = value), and broken doxygen comments. I fixed both, and I also 
removed an unneeded check for a dot in the file extension, since the 
extensions as used in the formats class never include the dot, and it is 
always better to be explicit.
I did not change the uppercase enums (they are also forbidden by 
development/Code_rules/Rules) because I was too lazy.

This is going in now.


Georg

Log:
        * src/support/os.h
        (canAutoOpenFile): correct comment
        (autoOpenFile): ditto

        * src/support/os_win32.C
        (canAutoOpenFile): Remove unneeded test for dot
        (autoOpenFile): whitespace

        * src/support/os_cygwin.C
        (canAutoOpenFile): Remove unneeded test for dot
        (autoOpenFile): whitespace
Index: src/support/os.h
===================================================================
--- src/support/os.h	(Revision 13865)
+++ src/support/os.h	(Arbeitskopie)
@@ -85,19 +85,19 @@ enum auto_open_mode {
 	EDIT
 };
 
-/** Check whether or not a file can be viewed by a default viewer 
+/** Check whether or not a file can be opened by a default viewer or editor.
  *  \param extension (without leading .)
- *  \mode can be opened in VIEW or EDIT mode
- *  \returns whether or not the format can be viewed
+ *  \param mode can be opened in VIEW or EDIT mode
+ *  \returns whether or not the format can be opened according to \p mode
  */
-bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode=VIEW);
+bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
 
-/** view a file, with given command and parameter.
- *  \param filename
+/** View or edit a file with the default viewer or editor.
+ *  \param filename file to open
  *  \param mode open in VIEW or EDIT mode
  *  \returns whether or not the file is viewed (or edited) successfully.
  */
-bool autoOpenFile(std::string const & filename, auto_open_mode const mode=VIEW);
+bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
 
 } // namespace os
 } // namespace support
Index: src/support/os_win32.C
===================================================================
--- src/support/os_win32.C	(Revision 13865)
+++ src/support/os_win32.C	(Arbeitskopie)
@@ -397,11 +397,8 @@ bool canAutoOpenFile(string const & ext,
 {
 	if (ext.empty())
 		return false;
-	
-	string full_ext = ext;
-	// if the extension is passed without leading dot
-	if (full_ext[0] != '.')
-		full_ext = "." + ext;
+
+	string const full_ext = "." + ext;
 
 	DWORD bufSize = MAX_PATH + 100;
 	TCHAR buf[MAX_PATH + 100];
@@ -418,7 +415,7 @@ bool autoOpenFile(string const & filenam
 	// reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc
 	//                 /platform/shell/reference/functions/shellexecute.asp
 	char const * action = (mode == VIEW) ? "open" : "edit";
-	return reinterpret_cast<int>(ShellExecute(NULL, action, 
+	return reinterpret_cast<int>(ShellExecute(NULL, action,
 		filename.c_str(), NULL, NULL, 1)) > 32;
 }
 
Index: src/support/os_cygwin.C
===================================================================
--- src/support/os_cygwin.C	(Revision 13865)
+++ src/support/os_cygwin.C	(Arbeitskopie)
@@ -278,11 +278,8 @@ bool canAutoOpenFile(string const & ext,
 {
 	if (ext.empty())
 		return false;
-	
-	string full_ext = ext;
-	// if the extension is passed without leading dot
-	if (full_ext[0] != '.')
-		full_ext = "." + ext;
+
+	string const full_ext = "." + ext;
 
 	DWORD bufSize = MAX_PATH + 100;
 	TCHAR buf[MAX_PATH + 100];
@@ -301,7 +298,7 @@ bool autoOpenFile(string const & filenam
 	string const win_path =
 		os::convert_path(filename, os::PathStyle(os::windows));
 	char const * action = (mode == VIEW) ? "open" : "edit";
-	return reinterpret_cast<int>(ShellExecute(NULL, action, 
+	return reinterpret_cast<int>(ShellExecute(NULL, action,
 		win_path.c_str(), NULL, NULL, 1)) > 32;
 }
 

Reply via email to