"John D. Blair" <[EMAIL PROTECTED]> writes:

A couple of _small_ comments on the code. Jurgen, you should read this
too.

| +     // jdblair: experimental date-insert command
| +     newFunc(LFUN_DATE_INSERT,"date-insert",
| +             "", Noop);

                ^ I know that I have been lazy, but it is always nice
to have a good helptext/description here.

|  #include <config.h>
| +#include <time.h>
|  
|  #include <cstdlib>
|  #include <cctype>
| @@ -2440,6 +2441,30 @@
|               }
|       }
|       break;
| +
| +     case LFUN_DATE_INSERT:  // jdblair: experimental date-insert cmd
| +       {
| +         char datetmp[32];
| +         int datetmp_len;
| +         time_t now_time_t;
| +         struct tm *now_tm;
| +         
| +         now_time_t = time(NULL);
| +         now_tm = localtime(&now_time_t);

In C++ we always try to give variables the smalest scope possible, and
we don't declare the variables before they are needed so:

        time_t now_time = time(0); // we don't use NULL and now_time_t
                                   // is not a type
        struct tm * now_tm = localtime(&now_time);

| +         
| +         datetmp_len = (int) strftime(datetmp, 32,
|                                        argument.c_str(), now_tm);

        We don't use C style cast, but use C++ style casts instead:
        
        int datetmp_len = static_cast<int>(strftime(datetmp, 32,
                                           argument.c_str(), now_tm);

        Is the cast really needed?

| +         for (int i = 0; i < datetmp_len; i++) {

In C++ it is adviced to use preincrement instead of postincrement:

        for (int i = 0; i < datetmp_len; ++i) {

| +           owner->buffer()->text->InsertChar(datetmp[i]);
| +           SmallUpdate(1);  // as done in LFUN_SELF_UPDATE (jdblair>
| +         }
| +         SetUpdateTimer();
| +         owner->buffer()->text->sel_cursor = 
| +           owner->buffer()->text->cursor;
| +         moveCursorUpdate(false);
| +         
| +       }
| +       break;
| +         

And I would really have liked to see this as a function instead of all
the code inside the dispatch switch.

        Lgb

PS. Most of the codeing rules can be found in development/Code_rules/

Reply via email to