Reuti writes:

> yes, it's a known bug. The backspace should rub out an already printed 0:
>
> http://arc.liv.ac.uk/pipermail/gridengine-users/2010-March/029490.html

Ok, here's my take on this

Problem is that the formatting string needs to accommodate both digits and
the string INFINITY

You thus use

%d%s

and you print a "" if it's not INFINITY but have to use a backspace, to
bin the 0 already printed, if it is.

#define FORMAT_LIMIT(x) (x==RLIMIT_INFINITY)?0:x,
(x==RLIMIT_INFINITY)?"\bINFINITY":""

Given that you already rewrite the limit, (x), why not rewrite it as:

#define FORMAT_LIMIT(x) (x==RLIMIT_INFINITY)?"INFINITY":x

but define the format string to be used based on the value of (x) as well

#define FORMAT_LIMIT_STR(x)
(x==RLIMIT_INFINITY)?"%s":"%some_value_for_various_int_sizes"

So further down the code, this would be the equivalent (I have left the
original #define and my suggestions in here for inspection)

#if defined(NECSX4) || defined(NECSX5) || defined(NETBSD_ALPHA) ||
defined(NETBSD_X86_64) || defined(NETBSD_SPARC64)
#  define limit_fmt "%ld%s"
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"%s":"%ld"
#elif defined(IRIX) || defined(HPUX) || defined(DARWIN) ||
defined(FREEBSD) || defined(NETBSD) || defined(INTERIX)
#  define limit_fmt "%lld%s"
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"%s":"%lld"
#elif (defined(LINUX) && defined(TARGET_32BIT))
#  define limit_fmt "%llu%s"
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"%s":"%llu"
#elif defined(ALPHA) || defined(SOLARIS) || defined(LINUX)
#  define limit_fmt "%lu%s"
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"%s":"%lu"
#else
#  define limit_fmt "%d%s"
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"%s":"%d"
#endif

and then replace instances of limit_fmt with FORMAT_LIMIT_STR(x)

Can anyone see a problem with that?

If not, and I will certainly give it a go locally, I'll create
a patch.

Kevin

-- 
Kevin M. Buckley                                  Room:  CO327
School of Engineering and                         Phone: +64 4 463 5971
 Computer Science
Victoria University of Wellington
New Zealand

_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to