- More file conversions.
This commit is contained in:
Paul Beckingham 2011-06-11 14:57:11 -04:00
parent 63e6c08fdd
commit 76b30d8d10
11 changed files with 66 additions and 39 deletions

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>

View file

@ -25,13 +25,17 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <fstream> #include <fstream>
#include <sys/types.h> #include <sys/types.h>
#include <sys/file.h> #include <sys/file.h>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <File.h> #include <File.h>
#include <text.h>
#include <util.h> #include <util.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::File () File::File ()
@ -107,8 +111,7 @@ bool File::open ()
bool already_exists = exists (); bool already_exists = exists ();
if (already_exists) if (already_exists)
if (!readable () || !writable ()) if (!readable () || !writable ())
throw std::string ("Task does not have the correct permissions for '") + throw std::string (format (STRING_FILE_PERMS, data));
data + "'.";
fh = fopen (data.c_str (), (already_exists ? "r+" : "w+")); fh = fopen (data.c_str (), (already_exists ? "r+" : "w+"));
if (fh) if (fh)

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <fstream> #include <fstream>
#include <glob.h> #include <glob.h>
#include <sys/types.h> #include <sys/types.h>

View file

@ -24,6 +24,9 @@
// USA // USA
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>

View file

@ -86,28 +86,6 @@
#ifndef INCLUDED_STRINGS #ifndef INCLUDED_STRINGS
#define INCLUDED_STRINGS #define INCLUDED_STRINGS
// Errors
#define STRING_UNKNOWN_ERROR "Unknown error."
#define STRING_NO_HOME "Could not read home directory from the passwd file."
#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas."
#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify."
#define STRING_ASSUME_INFO "No command - assuming 'info'"
// 'show' command
#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring."
#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string."
#define STRING_CMD_SHOW_NONE "No matching configuration variables."
#define STRING_CMD_SHOW_UNREC "Your .taskrc file contains these unrecognized variables:"
#define STRING_CMD_SHOW_DIFFER "Some of your .taskrc variables differ from the default values."
#define STRING_CMD_SHOW_HOOKS "Your .taskrc file contains these missing or unreadable hook scripts:"
#define STRING_CMD_SHOW_EMPTY "Configuration error: .taskrc contains no entries."
#define STRING_CMD_SHOW_DIFFER_COLOR "These are highlighted in {1} above."
#define STRING_CMD_SHOW_CONFIG_ERROR "Configuration error: {1} contains an unrecognized value '{2}'."
#define STRING_CMD_SHOW_NO_LOCATION "Configuration error: data.location not specified in .taskrc file."
#define STRING_CMD_SHOW_LOC_EXIST "Configuration error: data.location contains a directory name that doesn't exist, or is unreadable."
#define STRING_CMD_SHOW_CONF_VAR "Config Variable"
#define STRING_CMD_SHOW_CONF_VALUE "Value"
// API // API
#define STRING_API_EXITING "Exiting." #define STRING_API_EXITING "Exiting."
#define STRING_API_NOFUNC "The Lua function '{1}' was not found." #define STRING_API_NOFUNC "The Lua function '{1}' was not found."
@ -129,9 +107,44 @@
#define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'." #define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'."
#define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'." #define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'."
// Errors
// TODO Move each of these to appropriate section.
#define STRING_UNKNOWN_ERROR "Unknown error."
#define STRING_NO_HOME "Could not read home directory from the passwd file."
#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas."
#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify."
#define STRING_ASSUME_INFO "No command - assuming 'info'"
// File
#define STRING_FILE_PERMS "Task does not have the correct permissions for '{1}'."
// Lua // Lua
#define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'." #define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'."
#define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'." #define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'."
// 'show' command
#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring."
#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string."
#define STRING_CMD_SHOW_NONE "No matching configuration variables."
#define STRING_CMD_SHOW_UNREC "Your .taskrc file contains these unrecognized variables:"
#define STRING_CMD_SHOW_DIFFER "Some of your .taskrc variables differ from the default values."
#define STRING_CMD_SHOW_HOOKS "Your .taskrc file contains these missing or unreadable hook scripts:"
#define STRING_CMD_SHOW_EMPTY "Configuration error: .taskrc contains no entries."
#define STRING_CMD_SHOW_DIFFER_COLOR "These are highlighted in {1} above."
#define STRING_CMD_SHOW_CONFIG_ERROR "Configuration error: {1} contains an unrecognized value '{2}'."
#define STRING_CMD_SHOW_NO_LOCATION "Configuration error: data.location not specified in .taskrc file."
#define STRING_CMD_SHOW_LOC_EXIST "Configuration error: data.location contains a directory name that doesn't exist, or is unreadable."
#define STRING_CMD_SHOW_CONF_VAR "Config Variable"
#define STRING_CMD_SHOW_CONF_VALUE "Value"
// text
// A comma-separated list of commands is appended.
#define STRING_TEXT_AMBIGUOUS "Ambiguous {1} '{2}' - could be either of "
// utf8
#define STRING_UTF8_INVALID_CP_REP "Invalid codepoint representation."
#define STRING_UTF8_INVALID_CP "Invalid Unicode codepoint."
#endif #endif

View file

@ -25,11 +25,14 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <Context.h> #include <Context.h>
#include <main.h> #include <main.h>
#include <text.h>
#include <i18n.h> #include <i18n.h>
#include <cmake.h> #include <cmake.h>
@ -58,9 +61,7 @@ int Context::getWidth ()
terminal_height = buff[0]; terminal_height = buff[0];
terminal_width = buff[1]; terminal_width = buff[1];
std::stringstream out; debug (format ("Context::getWidth: determined width of {1} characters", terminal_width));
out << "Context::getWidth: determined width of " << terminal_width << " characters";
debug (out.str ());
} }
} }
@ -92,9 +93,7 @@ int Context::getHeight ()
terminal_height = buff[0]; terminal_height = buff[0];
terminal_width = buff[1]; terminal_width = buff[1];
std::stringstream out; debug (format ("Context::getHeight: determined height of {1} characters", terminal_height));
out << "Context::getWidth: determined height of " << terminal_height << " characters";
debug (out.str ());
} }
} }

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <stdlib.h> #include <stdlib.h>

View file

@ -25,7 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <iostream> // TODO Remove #define L10N // Localization complete.
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <string> #include <string>

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -37,6 +39,7 @@
#include <util.h> #include <util.h>
#include <text.h> #include <text.h>
#include <utf8.h> #include <utf8.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -494,11 +497,7 @@ void guess (
{ {
std::sort (matches.begin (), matches.end ()); std::sort (matches.begin (), matches.end ());
std::string error = "Ambiguous "; // TODO i18n std::string error = format (STRING_TEXT_AMBIGUOUS, type, candidate);
error += type;
error += " '";
error += candidate;
error += "' - could be either of "; // TODO i18n
for (size_t i = 0; i < matches.size (); ++i) for (size_t i = 0; i < matches.size (); ++i)
{ {
if (i) if (i)

View file

@ -76,7 +76,7 @@ const std::string format (const std::string&, const std::string&);
const std::string format (const std::string&, int); const std::string format (const std::string&, int);
const std::string format (const std::string&, const std::string&, const std::string&); const std::string format (const std::string&, const std::string&, const std::string&);
const std::string format (const std::string&, const std::string&, int); const std::string format (const std::string&, const std::string&, int);
const std::string format (const std::string&, int, const std::string& arg2); const std::string format (const std::string&, int, const std::string&);
const std::string format (const std::string&, int, int); const std::string format (const std::string&, int, int);
const std::string format (const std::string&, const std::string&, const std::string&, const std::string&); const std::string format (const std::string&, const std::string&, const std::string&, const std::string&);

View file

@ -25,8 +25,11 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <string> #include <string>
#include <utf8.h> #include <utf8.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Converts '0' -> 0 // Converts '0' -> 0
@ -65,7 +68,7 @@ unsigned int utf8_codepoint (const std::string& input)
XDIGIT (input[3]); XDIGIT (input[3]);
} }
else else
throw std::string ("Invalid codepoint representation."); throw std::string (STRING_UTF8_INVALID_CP_REP);
return codepoint; return codepoint;
} }
@ -144,7 +147,7 @@ std::string utf8_character (unsigned int codepoint)
sequence[4] = 0; sequence[4] = 0;
} }
else else
throw std::string ("Invalid Unicode codepoint."); throw std::string (STRING_UTF8_INVALID_CP);
sequence[4] = '\0'; sequence[4] = '\0';
return std::string (sequence); return std::string (sequence);