}
-
-
BC_FileBoxTextBox::BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox)
: BC_TextBox(x, y, filebox->get_w() - 20, 1,
filebox->want_directory ? filebox->directory : filebox->filename)
{
}
-
-
-
int BC_FileBoxTextBox::handle_event()
{
int result = 0;
}
-
-
BC_FileBoxDirectoryText::BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox)
: BC_TextBox(x, y, filebox->get_w() - 40, 1, filebox->fs->get_current_dir())
{
}
-
-
-
BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
: BC_TextBox(x, y, filebox->get_w() - 50, 1, filebox->get_resources()->filebox_filter)
{
}
-
-
BC_FileBoxFilterMenu::BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox)
- : BC_ListBox(x,
- y,
- filebox->get_w() - 30,
- 120,
- LISTBOX_TEXT,
- &filebox->filter_list,
- 0,
- 0,
- 1,
- 0,
- 1)
+ : BC_ListBox(x, y, filebox->get_w() - 30, 120,
+ LISTBOX_TEXT, &filebox->filter_list, 0, 0, 1, 0, 1)
{
this->filebox = filebox;
set_tooltip(_("Change the filter"));
}
-
-
-
-
-
-
-
-
-BC_FileBoxCancel::BC_FileBoxCancel(BC_FileBox *filebox)
- : BC_CancelButton(filebox)
+BC_FileBoxSizeFormat::BC_FileBoxSizeFormat(int x, int y, BC_FileBox *file_box)
+ : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_szfmt_images)
{
- this->filebox = filebox;
- set_tooltip(_("Cancel the operation"));
+ this->file_box = file_box;
+ set_tooltip(_("Size numeric format"));
}
-
-BC_FileBoxCancel::~BC_FileBoxCancel()
+BC_FileBoxSizeFormat::~BC_FileBoxSizeFormat()
{
}
-int BC_FileBoxCancel::handle_event()
+int BC_FileBoxSizeFormat::handle_event()
{
-// filebox->submit_file(filebox->textbox->get_text());
- filebox->newfolder_thread->interrupt();
- filebox->set_done(1);
+ if( ++file_box->size_format > FILEBOX_SIZE_THOU )
+ file_box->size_format = FILEBOX_SIZE_RAW;
+ BC_WindowBase::get_resources()->filebox_size_format = file_box->size_format;
+ file_box->refresh(0);
return 1;
}
-
-
-
-
-
BC_FileBoxUseThis::BC_FileBoxUseThis(BC_FileBox *filebox)
: BC_Button(filebox->get_w() / 2 -
BC_WindowBase::get_resources()->usethis_button_images[0]->get_w() / 2,
}
-
-
-
BC_FileBoxOK::BC_FileBoxOK(BC_FileBox *filebox)
: BC_OKButton(filebox,
!filebox->want_directory ?
return 1;
}
+BC_FileBoxCancel::BC_FileBoxCancel(BC_FileBox *filebox)
+ : BC_CancelButton(filebox)
+{
+ this->filebox = filebox;
+ set_tooltip(_("Cancel the operation"));
+}
+
+BC_FileBoxCancel::~BC_FileBoxCancel()
+{
+}
+
+int BC_FileBoxCancel::handle_event()
+{
+// filebox->submit_file(filebox->textbox->get_text());
+ filebox->newfolder_thread->interrupt();
+ filebox->set_done(1);
+ return 1;
+}
+
+
BC_FileBoxText::BC_FileBoxText(int x, int y, BC_FileBox *filebox)
: BC_Button(x, y, BC_WindowBase::get_resources()->filebox_text_images)
-
-
-
-
-
-
-
BC_FileBox::BC_FileBox(int x, int y, const char *init_path,
const char *title, const char *caption, int show_all_files,
int want_directory, int multiple_files, int h_padding)
filter_text = 0;
filter_popup = 0;
usethis_button = 0;
+ size_format = BC_WindowBase::get_resources()->filebox_size_format;
strcpy(this->caption, caption);
strcpy(this->current_path, init_path);
x -= resources->filebox_updir_images[0]->get_w() + 5;
add_subwindow(updir_button = new BC_FileBoxUpdir(x, y, this));
+ x -= resources->filebox_szfmt_images[0]->get_w() + 5;
+
+ add_subwindow(szfmt_button = new BC_FileBoxSizeFormat(x, y, this));
x = 10;
y += directory_title_margin + 3;
reload_button->reposition_window(reload_button->get_x()+dx, reload_button->get_y());
delete_button->reposition_window(delete_button->get_x()+dx, delete_button->get_y());
updir_button->reposition_window(updir_button->get_x()+dx, updir_button->get_y());
+ szfmt_button->reposition_window(szfmt_button->get_x()+dx, szfmt_button->get_y());
set_w(w); set_h(h);
get_resources()->filebox_w = get_w();
get_resources()->filebox_h = get_h();
if(!is_dir)
{
int64_t size = file_item->size;
-#if 1
- int len = 1;
- static const char *suffix[] = { "", "K", "M", "G", "T", "P" };
- for( int64_t s=size; len<15 && (s/=10)>0; ++len );
- int drop = len-3;
- if( drop > 0 ) {
+ if( (size_format == FILEBOX_SIZE_1000 && size >= 1000) ||
+ (size_format == FILEBOX_SIZE_1024 && size >= 1024) ) {
+ static const char *suffix[] = { "", "K", "M", "G", "T", "P" };
+ if( size_format == FILEBOX_SIZE_1024 ) {
+ static const long double kk = logl(1000.)/logl(1024.);
+ size = expl(kk*logl((long double)size)) + 0.5;
+ }
+ int len = 1;
+ for( int64_t s=size; len<16 && (s/=10)>0; ++len );
+ int drop = len-3;
size /= ipow(10,drop);
int sfx = (len-1)/3;
int digits = (sfx+1)*3 - len;
int64_t frac = ipow(10,digits);
- int mantisa = size / frac;
- int fraction = size - mantisa*frac;
+ int mant = size / frac;
+ int fraction = size - mant*frac;
if( fraction )
- sprintf(string, "%d.%0*d%s", mantisa, digits, fraction, suffix[sfx]);
+ sprintf(string, "%d.%0*d%s",
+ mant, digits, fraction, suffix[sfx]);
else
- sprintf(string, "%d%s", mantisa, suffix[sfx]);
+ sprintf(string, "%d%s",
+ mant, suffix[sfx]);
}
- else
-#endif
+ else {
sprintf(string, "%jd", size);
+ if( size_format == FILEBOX_SIZE_THOU )
+ Units::punctuate(string);
+ }
new_item = new BC_ListBoxItem(string, get_resources()->file_color);
}
else
BC_FileBox *filebox;
};
-class BC_FileBoxOK : public BC_OKButton
+class BC_FileBoxUseThis : public BC_Button
{
public:
- BC_FileBoxOK(BC_FileBox *filebox);
- ~BC_FileBoxOK();
-
+ BC_FileBoxUseThis(BC_FileBox *filebox);
+ ~BC_FileBoxUseThis();
int handle_event();
BC_FileBox *filebox;
};
-class BC_FileBoxUseThis : public BC_Button
+class BC_FileBoxOK : public BC_OKButton
{
public:
- BC_FileBoxUseThis(BC_FileBox *filebox);
- ~BC_FileBoxUseThis();
+ BC_FileBoxOK(BC_FileBox *filebox);
+ ~BC_FileBoxOK();
+
int handle_event();
BC_FileBox *filebox;
BC_FileBox *filebox;
};
+class BC_FileBoxSizeFormat : public BC_Button
+{
+public:
+ BC_FileBoxSizeFormat(int x, int y, BC_FileBox *file_box);
+ ~BC_FileBoxSizeFormat();
+
+ int handle_event();
+ BC_FileBox *file_box;
+};
class BC_FileBoxRecent : public BC_ListBox
friend class BC_FileBoxDelete;
friend class BC_FileBoxReload;
friend class BC_FileBoxRecent;
+ friend class BC_FileBoxSizeFormat;
virtual void create_objects();
virtual int keypress_event();
BC_Button *updir_button;
BC_Button *delete_button;
BC_Button *reload_button;
+ BC_FileBoxSizeFormat *szfmt_button;
BC_Button *ok_button, *cancel_button;
BC_FileBoxUseThis *usethis_button;
char caption[BCTEXTLEN];
int sort_column;
int sort_order;
+ int size_format;
const char *column_titles[FILEBOX_COLUMNS];
ArrayList<BC_ListBoxItem*> filter_list;
#define FILEBOX_DATE 2
#define FILEBOX_EXTENSION 3
+#define FILEBOX_SIZE_RAW 0
+#define FILEBOX_SIZE_1000 1
+#define FILEBOX_SIZE_1024 2
+#define FILEBOX_SIZE_THOU 3
+
#define FILEBOX_NAME_TEXT _("File")
#define FILEBOX_SIZE_TEXT _("Size")
#define FILEBOX_DATE_TEXT _("Date")
VFrame *BC_Resources::default_filebox_rename_images[3] = { 0, };
VFrame *BC_Resources::default_filebox_delete_images[3] = { 0, };
VFrame *BC_Resources::default_filebox_reload_images[3] = { 0, };
+VFrame *BC_Resources::default_filebox_szfmt_images[3] = { 0, };
VFrame *BC_Resources::default_listbox_button[4] = { 0, };
VFrame *BC_Resources::default_listbox_bg = 0;
VFrame *BC_Resources::default_listbox_expand[5] = { 0, };
#include "images/file_reload_up_png.h"
#include "images/file_reload_hi_png.h"
#include "images/file_reload_dn_png.h"
+#include "images/file_size_fmt_up_png.h"
+#include "images/file_size_fmt_hi_png.h"
+#include "images/file_size_fmt_dn_png.h"
+
new_vframes(3,default_filebox_text_images,
new VFramePng(file_text_up_png),
new VFramePng(file_text_hi_png),
new VFramePng(file_reload_hi_png),
new VFramePng(file_reload_dn_png));
+new_vframes(3,default_filebox_szfmt_images,
+ new VFramePng(file_size_fmt_up_png),
+ new VFramePng(file_size_fmt_hi_png),
+ new VFramePng(file_size_fmt_dn_png));
+
#include "images/listbox_button_dn_png.h"
#include "images/listbox_button_hi_png.h"
#include "images/listbox_button_up_png.h"
filebox_rename_images = default_filebox_rename_images;
filebox_delete_images = default_filebox_delete_images;
filebox_reload_images = default_filebox_reload_images;
+ filebox_szfmt_images = default_filebox_szfmt_images;
+ filebox_size_format = FILEBOX_SIZE_RAW;
directory_color = BLUE;
file_color = BLACK;
del_vframes(default_filebox_rename_images, 3);
del_vframes(default_filebox_delete_images, 3);
del_vframes(default_filebox_reload_images, 3);
+ del_vframes(default_filebox_szfmt_images, 3);
del_vframes(default_listbox_button, 4);
delete default_listbox_bg;
del_vframes(default_listbox_expand, 5);
VFrame **filebox_descend_images;
VFrame **filebox_delete_images;
VFrame **filebox_reload_images;
+ VFrame **filebox_szfmt_images;
// Generic button images
VFrame **generic_button_images;
static VFrame *default_filebox_rename_images[3];
static VFrame *default_filebox_delete_images[3];
static VFrame *default_filebox_reload_images[3];
+ static VFrame *default_filebox_szfmt_images[3];
static VFrame *default_listbox_button[4];
static VFrame *default_listbox_bg;
static VFrame *default_listbox_expand[5];
int use_xvideo;
// Seems to help if only 1 window is created at a time.
Mutex *create_window_lock;
-
+// size raw, 1000, 1024, thou
+ int filebox_size_format;
private:
// Test for availability of shared memory pixmaps
void init_shm(BC_WindowBase *window);
resources->filebox_columnwidth[1] = defaults->get("FILEBOX_WIDTH1", resources->filebox_columnwidth[1]);
resources->filebox_columnwidth[2] = defaults->get("FILEBOX_WIDTH2", resources->filebox_columnwidth[2]);
resources->filebox_columnwidth[3] = defaults->get("FILEBOX_WIDTH3", resources->filebox_columnwidth[3]);
+ resources->filebox_size_format = defaults->get("FILEBOX_SIZE_FORMAT", get_resources()->filebox_size_format);
defaults->get("FILEBOX_FILTER", resources->filebox_filter);
return 0;
}
defaults->update("FILEBOX_WIDTH2", resources->filebox_columnwidth[2]);
defaults->update("FILEBOX_WIDTH3", resources->filebox_columnwidth[3]);
defaults->update("FILEBOX_FILTER", resources->filebox_filter);
+ defaults->update("FILEBOX_SIZE_FORMAT", get_resources()->filebox_size_format);
return 0;
}
--- /dev/null
+#ifndef FILE_SIZE_FMT_DN_PNG_H
+#define FILE_SIZE_FMT_DN_PNG_H
+
+static unsigned char file_size_fmt_dn_png[] =
+{
+ 0x00, 0x00, 0x01, 0x4e,
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x19, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0xe9, 0x85,
+ 0x63, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
+ 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00,
+ 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45,
+ 0x07, 0xe2, 0x02, 0x08, 0x0f, 0x32, 0x3b, 0x7f, 0x0b, 0x91, 0xce, 0x00, 0x00, 0x00, 0x21, 0x69,
+ 0x54, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43,
+ 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20,
+ 0x47, 0x49, 0x4d, 0x50, 0x6d, 0xb0, 0x97, 0x00, 0x00, 0x00, 0x00, 0xae, 0x49, 0x44, 0x41, 0x54,
+ 0x48, 0xc7, 0xcd, 0x96, 0xc1, 0x0e, 0x03, 0x21, 0x08, 0x44, 0x07, 0xc3, 0x77, 0x73, 0xe0, 0xc7,
+ 0xa7, 0x87, 0xa6, 0x89, 0xda, 0x56, 0x31, 0xe8, 0xee, 0x72, 0x36, 0x3c, 0x9d, 0x19, 0x82, 0x42,
+ 0x92, 0xa8, 0x4a, 0x44, 0x90, 0xad, 0xae, 0x25, 0xb4, 0x07, 0xb8, 0x7b, 0x1a, 0x22, 0x22, 0x0d,
+ 0xa8, 0xec, 0x06, 0x00, 0x80, 0xbb, 0x37, 0x8a, 0xe8, 0x3f, 0x80, 0x99, 0x85, 0x9a, 0xcd, 0x40,
+ 0x24, 0x21, 0x00, 0xf8, 0xeb, 0x70, 0x04, 0x12, 0x81, 0x99, 0x59, 0xeb, 0xc9, 0x4a, 0x93, 0xfa,
+ 0x12, 0x66, 0x36, 0x04, 0x95, 0x8c, 0xee, 0xd1, 0x2a, 0x59, 0x83, 0x8f, 0x43, 0x2e, 0x79, 0x49,
+ 0x34, 0x1c, 0x65, 0x07, 0x60, 0x26, 0x9b, 0x66, 0x6f, 0x1c, 0xf1, 0x25, 0xed, 0x49, 0x44, 0x32,
+ 0xcd, 0xa4, 0xe8, 0x03, 0x38, 0x36, 0x27, 0xb7, 0x44, 0x78, 0x24, 0xdb, 0xf3, 0xe7, 0xe4, 0xf2,
+ 0x61, 0x1c, 0xf9, 0xa3, 0x3b, 0x62, 0x3a, 0x0b, 0x40, 0x5a, 0xae, 0x48, 0xc2, 0x84, 0x24, 0x77,
+ 0xae, 0xde, 0x5e, 0x01, 0x92, 0xef, 0x97, 0x90, 0x5c, 0xda, 0x84, 0x2b, 0x80, 0x46, 0xae, 0x9d,
+ 0xa0, 0x1a, 0xf0, 0x65, 0x3c, 0xc9, 0x23, 0xff, 0xae, 0x17, 0x77, 0x17, 0x63, 0x3e, 0xb4, 0x01,
+ 0x4c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
+#endif
--- /dev/null
+#ifndef FILE_SIZE_FMT_HI_PNG_H
+#define FILE_SIZE_FMT_HI_PNG_H
+
+static unsigned char file_size_fmt_hi_png[] =
+{
+ 0x00, 0x00, 0x01, 0x3b,
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x19, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0xe9, 0x85,
+ 0x63, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
+ 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00,
+ 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45,
+ 0x07, 0xe2, 0x02, 0x08, 0x0f, 0x2e, 0x26, 0xfa, 0x7a, 0xa0, 0x4a, 0x00, 0x00, 0x00, 0x21, 0x69,
+ 0x54, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43,
+ 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20,
+ 0x47, 0x49, 0x4d, 0x50, 0x6d, 0xb0, 0x97, 0x00, 0x00, 0x00, 0x00, 0x9b, 0x49, 0x44, 0x41, 0x54,
+ 0x48, 0xc7, 0xd5, 0x56, 0x41, 0x0a, 0xc0, 0x30, 0x08, 0xab, 0xc1, 0xff, 0x7f, 0xd9, 0x1d, 0x46,
+ 0x41, 0xa4, 0xba, 0xad, 0x4b, 0x3b, 0xe6, 0xad, 0x50, 0x8c, 0xc6, 0x04, 0x15, 0x33, 0xb3, 0xe6,
+ 0x42, 0x44, 0xda, 0xdb, 0x08, 0x29, 0x9b, 0x46, 0x80, 0xf8, 0x61, 0x26, 0x62, 0x1e, 0xb0, 0x01,
+ 0x7a, 0x27, 0x9e, 0x11, 0xb0, 0x01, 0x46, 0x40, 0x72, 0xbe, 0x2d, 0x6d, 0xfb, 0x29, 0xff, 0xa3,
+ 0x1c, 0x60, 0xf0, 0x7f, 0x55, 0x8c, 0xce, 0x2a, 0x26, 0x76, 0x5a, 0x51, 0x0e, 0xa6, 0x54, 0xb3,
+ 0x00, 0xdb, 0x13, 0x4b, 0x40, 0xb6, 0x74, 0x72, 0x47, 0x81, 0x60, 0x01, 0x54, 0xb4, 0x29, 0xa3,
+ 0xe2, 0xab, 0xb9, 0x50, 0x66, 0xb2, 0xd4, 0x27, 0x1e, 0x60, 0x99, 0x4f, 0x3e, 0x91, 0x70, 0x46,
+ 0xdb, 0x3f, 0x7c, 0xb2, 0xdd, 0x8c, 0xd9, 0x7c, 0x94, 0x25, 0xd3, 0x4a, 0x00, 0x88, 0xab, 0x92,
+ 0xa9, 0xb0, 0x2e, 0x6b, 0xe9, 0x6b, 0x91, 0xbd, 0x82, 0x7d, 0x3e, 0x64, 0xcb, 0x9f, 0x79, 0xad,
+ 0x68, 0x75, 0x65, 0xb0, 0xe8, 0x3b, 0x00, 0x46, 0x97, 0x60, 0x33, 0x27, 0x00, 0x36, 0xeb, 0x00,
+ 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
+#endif
--- /dev/null
+#ifndef FILE_SIZE_FMT_UP_PNG_H
+#define FILE_SIZE_FMT_UP_PNG_H
+
+static unsigned char file_size_fmt_up_png[] =
+{
+ 0x00, 0x00, 0x01, 0x41,
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
+ 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x19, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0xe9, 0x85,
+ 0x63, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
+ 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00,
+ 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45,
+ 0x07, 0xe2, 0x02, 0x08, 0x0f, 0x2f, 0x2d, 0x74, 0xb3, 0x48, 0x83, 0x00, 0x00, 0x00, 0x21, 0x69,
+ 0x54, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43,
+ 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20,
+ 0x47, 0x49, 0x4d, 0x50, 0x6d, 0xb0, 0x97, 0x00, 0x00, 0x00, 0x00, 0xa1, 0x49, 0x44, 0x41, 0x54,
+ 0x48, 0xc7, 0xcd, 0x56, 0x41, 0x0e, 0xc0, 0x20, 0x08, 0x13, 0xc2, 0xff, 0xbf, 0xdc, 0x1d, 0x16,
+ 0x13, 0x47, 0x1c, 0x12, 0xad, 0x6e, 0xbd, 0x99, 0x18, 0x0a, 0xa5, 0x88, 0x02, 0x00, 0xa5, 0x81,
+ 0x88, 0x94, 0x55, 0xb8, 0x90, 0xc5, 0x3c, 0x81, 0xbf, 0x30, 0x03, 0x1f, 0x47, 0xd9, 0x04, 0xb5,
+ 0x92, 0x56, 0x11, 0x7b, 0x23, 0xc8, 0xc8, 0x16, 0x25, 0x55, 0x89, 0x00, 0x14, 0xb9, 0xcf, 0xe8,
+ 0x96, 0x3c, 0xdb, 0x03, 0x1f, 0xc7, 0x66, 0x83, 0xb4, 0x49, 0x8c, 0xa4, 0x56, 0x96, 0x83, 0x22,
+ 0x28, 0xd3, 0xaa, 0x5b, 0x48, 0x8e, 0x54, 0x92, 0x35, 0x87, 0x32, 0x08, 0x46, 0xb2, 0xd9, 0x6a,
+ 0xc6, 0x99, 0xbe, 0x28, 0xe3, 0x09, 0x19, 0xc1, 0x56, 0x5c, 0x54, 0x09, 0xb6, 0xcd, 0xc9, 0x27,
+ 0x16, 0x8e, 0x64, 0xfb, 0xff, 0x9c, 0x1c, 0x1f, 0xc6, 0xa8, 0x3f, 0xc6, 0xb0, 0xe9, 0xc8, 0x00,
+ 0xcb, 0x72, 0x65, 0x1c, 0x26, 0x00, 0xc0, 0x5c, 0xbd, 0xbd, 0x5d, 0xaf, 0xbd, 0x9d, 0xcc, 0x24,
+ 0x78, 0xc8, 0xc5, 0x24, 0xf2, 0xca, 0x58, 0xf4, 0xcb, 0x60, 0xf5, 0xe9, 0x02, 0x95, 0xa5, 0x66,
+ 0x2c, 0xf8, 0x7c, 0xed, 0xab, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
+ 0x82
+};
+
+#endif
void Units::punctuate(char *string)
{
- int len = strlen(string);
- int commas = (len - 1) / 3;
- for(int i = len + commas, j = len, k; j >= 0 && i >= 0; i--, j--) {
- k = (len - j - 1) / 3;
- if(k * 3 == len - j - 1 && j != len - 1 && string[j] != 0) {
- string[i--] = ',';
- }
- string[i] = string[j];
+ int sep = ',', len = strlen(string), commas = (len - 1) / 3;
+ char *cp = string + len, *bp = cp + commas;
+ *bp = 0;
+ for( int k=3; cp < bp && bp > string; ) {
+ *--bp = *--cp;
+ if( --k > 0 ) continue;
+ *--bp = sep; k = 3;
}
}