Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pacman/callback.c46
-rw-r--r--src/pacman/util.c36
-rw-r--r--src/pacman/util.h1
3 files changed, 39 insertions, 44 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index cc1b31c6..89c508cc 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -53,6 +53,42 @@ static struct timeval initial_time;
/* transaction progress bar ? */
static int prevpercent=0; /* for less progressbar output */
+/* Silly little helper function, determines if the caller needs a visual update
+ * since the last time this function was called.
+ * This is made for the two progress bar functions, to prevent flicker
+ *
+ * first_call indicates if this is the first time it is called, for
+ * initialization purposes */
+static float get_update_timediff(int first_call)
+{
+ float retval = 0.0;
+ static struct timeval last_time = {0};
+
+ /* on first call, simply set the last time and return */
+ if(first_call) {
+ gettimeofday(&last_time, NULL);
+ } else {
+ struct timeval this_time;
+ float diff_sec, diff_usec;
+
+ gettimeofday(&this_time, NULL);
+ diff_sec = this_time.tv_sec - last_time.tv_sec;
+ diff_usec = this_time.tv_usec - last_time.tv_usec;
+
+ retval = diff_sec + (diff_usec / 1000000.0);
+
+ /* return 0 and do not update last_time if interval was too short */
+ if(retval < UPDATE_SPEED_SEC) {
+ retval = 0.0;
+ } else {
+ last_time = this_time;
+ /* printf("\nupdate retval: %f\n", retval); DEBUG*/
+ }
+ }
+
+ return(retval);
+}
+
/* refactored from cb_trans_progress */
static void fill_progress(const int percent, const int proglen)
{
@@ -374,8 +410,6 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
}
if(percent == 0) {
- /* print a newline before we start our progressbar */
- printf("\n");
timediff = get_update_timediff(1);
} else {
timediff = get_update_timediff(0);
@@ -474,8 +508,6 @@ void cb_dl_progress(const char *filename, int xfered, int total)
/* this is basically a switch on xferred: 0, total, and anything else */
if(xfered == 0) {
- /* print a newline before we start our progressbar */
- printf("\n");
/* set default starting values */
gettimeofday(&initial_time, NULL);
xfered_last = 0;
@@ -608,12 +640,12 @@ void cb_log(pmloglevel_t level, char *msg)
strftime(timestr, 9, "%H:%M:%S", tmp);
timestr[8] = '\0';
- printf("[%s] %s: %s", timestr, str, msg);
+ printf("[%s] %s: %s\n", timestr, str, msg);
} else {
- printf("%s: %s", str, msg);
+ printf("%s: %s\n", str, msg);
}
#else
- printf("%s: %s", str, msg);
+ printf("%s: %s\n", str, msg);
#endif
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 3c623cd4..8d7be69b 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -336,40 +336,4 @@ void display_targets(alpm_list_t *syncpkgs)
FREELIST(targets);
}
-/* Silly little helper function, determines if the caller needs a visual update
- * since the last time this function was called.
- * This is made for the two progress bar functions, to prevent flicker
- *
- * first_call indicates if this is the first time it is called, for
- * initialization purposes */
-float get_update_timediff(int first_call)
-{
- float retval = 0.0;
- static struct timeval last_time = {0};
-
- /* on first call, simply set the last time and return */
- if(first_call) {
- gettimeofday(&last_time, NULL);
- } else {
- struct timeval this_time;
- float diff_sec, diff_usec;
-
- gettimeofday(&this_time, NULL);
- diff_sec = this_time.tv_sec - last_time.tv_sec;
- diff_usec = this_time.tv_usec - last_time.tv_usec;
-
- retval = diff_sec + (diff_usec / 1000000.0);
-
- /* return 0 and do not update last_time if interval was too short */
- if(retval < UPDATE_SPEED_SEC) {
- retval = 0.0;
- } else {
- last_time = this_time;
- /* printf("\nupdate retval: %f\n", retval); DEBUG*/
- }
- }
-
- return(retval);
-}
-
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/util.h b/src/pacman/util.h
index e43208aa..5ab3599e 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -42,7 +42,6 @@ char *strtrim(char *str);
int reg_match(char *string, char *pattern);
void list_display(const char *title, alpm_list_t *list);
void display_targets(alpm_list_t *syncpkgs);
-float get_update_timediff(int first_call);
#endif /* _PM_UTIL_H */