r413 - in trunk: . scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Jan 13 20:50:21 EST 2008
Author: icculus
Date: 2008-01-13 20:50:21 -0500 (Sun, 13 Jan 2008)
New Revision: 413
Modified:
trunk/gui_gtkplus2.c
trunk/gui_stdio.c
trunk/lua_glue.c
trunk/mojosetup.c
trunk/platform.h
trunk/platform_unix.c
trunk/platform_windows.c
trunk/scripts/localization.lua
trunk/scripts/mojosetup_mainline.lua
Log:
Lots of FIXME removals, clenaups, and tweaks.
Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/gui_gtkplus2.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -97,7 +97,6 @@
gtk_main_iteration();
if (click_value == CLICK_CANCEL)
{
- // !!! FIXME: language.
char *title = entry->xstrdup(entry->_("Cancel installation"));
char *text = entry->xstrdup(entry->_("Are you sure you want to cancel installation?"));
if (!MojoGui_gtkplus2_promptyn(title, text, false))
@@ -280,7 +279,6 @@
static boolean MojoGui_gtkplus2_promptyn(const char *title, const char *text,
boolean defval)
{
- // !!! FIXME: support defval.
gint rc = do_msgbox(title, text, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
defval ? GTK_RESPONSE_YES : GTK_RESPONSE_NO,
@@ -310,7 +308,6 @@
const char *text,
boolean defval)
{
- // !!! FIXME: support defval.
const gint rc = do_msgbox(title, text, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
defval ? GTK_RESPONSE_YES : GTK_RESPONSE_NO,
Modified: trunk/gui_stdio.c
===================================================================
--- trunk/gui_stdio.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/gui_stdio.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -621,7 +621,6 @@
char *fmt = NULL;
char *msg = NULL;
percentTicks = now + 1000;
- // !!! FIXME: localization.
if (percent < 0)
printf("%s\n", item);
else
Modified: trunk/lua_glue.c
===================================================================
--- trunk/lua_glue.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/lua_glue.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -988,7 +988,7 @@
size_t len = 0;
int retval = 0;
boolean rc = false;
- uint16 perms = 0600; // !!! FIXME
+ uint16 perms = MojoPlatform_defaultFilePerms();
MojoChecksums sums;
str = lua_tolstring(L, 1, &len);
@@ -1365,21 +1365,17 @@
size_t reccount = 0;
char *rc = NULL;
int command = 0;
+ size_t i = 0;
if (lua_istable(L, 1))
{
- size_t i;
-
reccount = lua_objlen(L, 1);
- recommend = (char **) alloca(reccount * sizeof (char *));
+ recommend = (char **) xmalloc(reccount * sizeof (char *));
for (i = 0; i < reccount; i++)
{
- const char *str = NULL;
lua_pushinteger(L, i+1);
lua_gettable(L, 1);
- str = lua_tostring(L, -1); // !!! FIXME: alloca in a loop...
- recommend[i] = (char *) alloca(strlen(str) + 1);
- strcpy(recommend[i], str);
+ recommend[i] = xstrdup(lua_tostring(L, -1));
lua_pop(L, 1);
} // for
} // if
@@ -1387,6 +1383,13 @@
rc = GGui->destination((const char **) recommend, reccount,
&command, can_go_back, can_go_fwd);
+ if (recommend != NULL)
+ {
+ for (i = 0; i < reccount; i++)
+ free(recommend[i]);
+ free(recommend);
+ } // if
+
retvalNumber(L, command);
retvalString(L, rc); // may push nil.
free(rc);
Modified: trunk/mojosetup.c
===================================================================
--- trunk/mojosetup.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/mojosetup.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -455,8 +455,9 @@
else // Unknown string gets everything...that'll teach you.
MojoLog_logLevel = MOJOSETUP_LOG_EVERYTHING;
- // !!! FIXME: allow logging to stdout on Unix.
- if (fname != NULL)
+ if ((fname != NULL) && (strcmp(fname, "-") == 0))
+ logFile = MojoPlatform_stdout();
+ else if (fname != NULL)
{
const uint32 flags = MOJOFILE_WRITE|MOJOFILE_CREATE|MOJOFILE_TRUNCATE;
const uint16 mode = MojoPlatform_defaultFilePerms();
Modified: trunk/platform.h
===================================================================
--- trunk/platform.h 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/platform.h 2008-01-14 01:50:21 UTC (rev 413)
@@ -147,6 +147,12 @@
// handle with MojoPlatform_close() when done with it.
void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode);
+// Return a handle that's compatible with MojoPlatform_open()'s return values
+// that represents stdout. May return NULL for platforms that don't support
+// this concept. You need to make sure that stdout itself doesn't really
+// close in MojoPlatform_close(), at least for now.
+void *MojoPlatform_stdout(void);
+
// Read (bytes) bytes from (fd) into (buf). This wraps the Unix read() syscall.
// Returns number of bytes read, -1 on error.
int64 MojoPlatform_read(void *fd, void *buf, uint32 bytes);
Modified: trunk/platform_unix.c
===================================================================
--- trunk/platform_unix.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/platform_unix.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -591,6 +591,14 @@
} // MojoPlatform_isfile
+void *MojoPlatform_stdout(void)
+{
+ int *retval = (int *) xmalloc(sizeof (int));
+ *retval = 1; // stdout.
+ return retval;
+} // MojoPlatform_stdout
+
+
void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode)
{
void *retval = NULL;
@@ -678,8 +686,17 @@
boolean MojoPlatform_close(void *fd)
{
boolean retval = false;
- if (close(*((int *) fd)) == 0)
+ int handle = *((int *) fd);
+
+ // don't close stdin, stdout, or stderr.
+ if ((handle == 0) || (handle == 1) || (handle == 2))
+ {
free(fd);
+ return true;
+ } // if
+
+ if (close(handle) == 0)
+ free(fd);
return retval;
} // MojoPlatform_close
Modified: trunk/platform_windows.c
===================================================================
--- trunk/platform_windows.c 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/platform_windows.c 2008-01-14 01:50:21 UTC (rev 413)
@@ -1132,6 +1132,12 @@
} // MojoPlatform_isfile
+void *MojoPlatform_stdout(void)
+{
+ return NULL; // unsupported on Windows.
+} // MojoPlatform_stdout
+
+
void *MojoPlatform_open(const char *fname, uint32 flags, uint16 mode)
{
HANDLE *retval = NULL;
Modified: trunk/scripts/localization.lua
===================================================================
--- trunk/scripts/localization.lua 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/scripts/localization.lua 2008-01-14 01:50:21 UTC (rev 413)
@@ -126,6 +126,10 @@
["NOTICE: %0\n[hit enter]"] = {
};
+ -- That's meant to be the name of an item (%0) and the percent done (%1).
+ ["%0: %1%%"] = {
+ };
+
["%0 (total progress: %1%%)\n"] = {
};
@@ -180,10 +184,10 @@
["Cancel installation"] = {
};
- ["cannot open archive."] = {
+ ["Can't enumerate archive"] = {
};
- ["Can't enumerate archive"] = {
+ ["Can't open archive."] = {
};
["Choose install destination by number (hit enter for #1), or enter your own."] = {
@@ -238,9 +242,12 @@
["File creation failed!"] = {
};
- ["file download failed!"] = {
+ ["File download failed!"] = {
};
+ ["File '$0' already exists! Replace?"] = {
+ };
+
["Finish"] = {
};
@@ -272,7 +279,7 @@
["Media change"] = {
};
- ["mkdir failed"] = {
+ ["Directory creation failed"] = {
};
["need dictionary"] = {
@@ -322,7 +329,7 @@
["(stalled)"] = {
};
- ["symlink creation failed!"] = {
+ ["Symlink creation failed!"] = {
};
["The installer has been stopped by the system."] = {
Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua 2008-01-14 01:01:23 UTC (rev 412)
+++ trunk/scripts/mojosetup_mainline.lua 2008-01-14 01:50:21 UTC (rev 413)
@@ -35,7 +35,6 @@
for i = max,1,-1 do
local fname = filelist[i]
if not do_delete(fname) and error_is_fatal then
- -- !!! FIXME: formatting
MojoSetup.fatal(_("Deletion failed!"))
end
@@ -77,7 +76,6 @@
local dest = MojoSetup.rollbacks[id]
if not MojoSetup.movefile(src, dest) then
-- we're already in fatal(), so we can only throw up a msgbox...
- -- !!! FIXME: formatting
MojoSetup.msgbox(_("Serious problem"),
_("Couldn't restore some files. Your existing installation is likely damaged."))
end
@@ -110,7 +108,6 @@
-- This gets called by fatal()...must be a global function.
function MojoSetup.revertinstall()
- -- !!! FIXME: language.
if MojoSetup.gui_started then
MojoSetup.gui.final(_("Incomplete installation. We will revert any changes we made."))
end
@@ -219,7 +216,7 @@
-- This code's a little nasty...
local function drill_for_archive(archive, path, arclist)
if not MojoSetup.archive.enumerate(archive) then
- MojoSetup.fatal(_("Couldn't enumerate archive.")) -- !!! FIXME: error message
+ MojoSetup.fatal(_("Couldn't enumerate archive."))
end
local pathtab = split_path(path)
@@ -237,7 +234,7 @@
-- open it as an archive and keep drilling...
local arc = MojoSetup.archive.fromentry(archive)
if arc == nil then
- MojoSetup.fatal(_("Couldn't open archive.")) -- !!! FIXME: error message.
+ MojoSetup.fatal(_("Couldn't open archive."))
end
arclist[#arclist+1] = arc
if pathtab[i] == nil then
@@ -249,14 +246,14 @@
ent = MojoSetup.archive.enumnext(archive)
end
- MojoSetup.fatal(_("Archive not found.")) -- !!! FIXME: error message.
+ MojoSetup.fatal(_("Archive not found."))
end
local function install_file(dest, perms, writefn, desc, manifestkey)
-- Upvalued so we don't look these up each time...
local fname = string.gsub(dest, "^.*/", "", 1) -- chop the dirs off...
- local ptype = _("Installing") -- !!! FIXME: localization.
+ local ptype = _("Installing")
local component = desc
local keepgoing = true
local callback = function(ticks, justwrote, bw, total)
@@ -265,7 +262,7 @@
if total >= 0 then
MojoSetup.written = MojoSetup.written + justwrote
percent = calc_percent(MojoSetup.written, MojoSetup.totalwrite)
- item = fname .. ": " .. calc_percent(bw, total) .. "%" -- !!! FIXME: localization
+ item = MojoSetup.format(_("%0: %1%%"), fname, calc_percent(bw, total))
end
keepgoing = MojoSetup.gui.progress(ptype, component, percent, item)
return keepgoing
@@ -288,7 +285,6 @@
local written, sums = writefn(callback)
if not written then
- -- !!! FIXME: formatting!
if not keepgoing then
MojoSetup.logerror("User cancelled install during file write.")
MojoSetup.fatal()
@@ -324,9 +320,8 @@
-- !!! FIXME: thousands of symlinks in a row or something.
local function install_symlink(dest, lndest, manifestkey)
if not MojoSetup.platform.symlink(dest, lndest) then
- -- !!! FIXME: formatting!
MojoSetup.logerror("Failed to create symlink '" .. dest .. "'")
- MojoSetup.fatal(_("symlink creation failed!"))
+ MojoSetup.fatal(_("Symlink creation failed!"))
end
if manifestkey ~= nil then
@@ -350,9 +345,8 @@
-- !!! FIXME: thousands of dirs in a row or something.
local function install_directory(dest, perms, manifestkey)
if not MojoSetup.platform.mkdir(dest, perms) then
- -- !!! FIXME: formatting
MojoSetup.logerror("Failed to create dir '" .. dest .. "'")
- MojoSetup.fatal(_("mkdir failed"))
+ MojoSetup.fatal(_("Directory creation failed"))
end
if manifestkey ~= nil then
@@ -404,7 +398,8 @@
if not allowoverwrite then
-- !!! FIXME: language and formatting.
MojoSetup.loginfo("File '" .. dest .. "' already exists.")
- local ynan = MojoSetup.promptynan(_("Conflict!"), _("File already exists! Replace?"), true)
+ local text = MojoSetup.format(_("File '$0' already exists! Replace?"), dest);
+ local ynan = MojoSetup.promptynan(_("Conflict!"), text, true)
if ynan == "always" then
MojoSetup.forceoverwrite = true
allowoverwrite = true
@@ -427,7 +422,6 @@
install_parent_dirs(f, nil)
MojoSetup.rollbacks[id] = dest
if not MojoSetup.movefile(dest, f) then
- -- !!! FIXME: formatting
MojoSetup.fatal(_("Couldn't backup file for rollback"))
end
MojoSetup.loginfo("Moved rollback #" .. id .. ": '" .. dest .. "' -> '" .. f .. "'")
@@ -472,7 +466,6 @@
elseif ent.type == "symlink" then
install_symlink(dest, ent.linkdest, option)
else -- !!! FIXME: device nodes, etc...
- -- !!! FIXME: formatting!
-- !!! FIXME: should this be fatal?
MojoSetup.fatal(_("Unknown file type in archive"))
end
@@ -483,7 +476,6 @@
local function install_archive(archive, file, option)
if not MojoSetup.archive.enumerate(archive) then
- -- !!! FIXME: need formatting function.
MojoSetup.fatal(_("Can't enumerate archive"))
end
@@ -562,8 +554,8 @@
local archive = MojoSetup.archive.fromdir(path)
if archive == nil then
archive = MojoSetup.archive.fromfile(path)
- if archive == nil then -- !!! FIXME: error message.
- MojoSetup.fatal(_("cannot open archive."))
+ if archive == nil then
+ MojoSetup.fatal(_("Can't open archive."))
end
end
return archive
@@ -583,7 +575,7 @@
local knowngood = path
path = path .. "/" .. v
if not MojoSetup.platform.exists(path) then
- if knowngood == "" then -- !!! FIXME: error message.
+ if knowngood == "" then
MojoSetup.fatal(_("Archive not found"))
end
local archive = create_basepath_archive(knowngood)
@@ -1093,7 +1085,7 @@
-- Upvalued so we don't look these up each time...
local url = file.source
local fname = string.gsub(url, "^.*/", "", 1) -- chop the dirs off...
- local ptype = _("Downloading") -- !!! FIXME: localization.
+ local ptype = _("Downloading")
local component = option.description
local bps = 0
local bpsticks = 0
@@ -1123,8 +1115,7 @@
MojoSetup.loginfo("Download '" .. url .. "' to '" .. f .. "'")
local downloaded, sums = MojoSetup.download(url, f, callback)
if not downloaded then
- -- !!! FIXME: formatting!
- MojoSetup.fatal(_("file download failed!"))
+ MojoSetup.fatal(_("File download failed!"))
end
MojoSetup.downloads[#MojoSetup.downloads+1] = f
end
@@ -1206,7 +1197,6 @@
-- Next stage: show results gui
stages[#stages+1] = function(thisstage, maxstage)
- -- !!! FIXME: language.
MojoSetup.gui.final(_("Installation was successful."))
return 1 -- go forward.
end
More information about the mojosetup-commits
mailing list