[Kmymoney-devel] Tweaks to astyle script?

Ian Neal iann_bugzilla at blueyonder.co.uk
Tue May 25 15:23:37 CEST 2010


  Thomas Baumgart wrote:
> On Tuesday 25 May 2010 14:38:29 Ian Neal wrote:
>>    Hi all,
>>
>> I've just been looking through mymoneyscheduled.cpp and noticed that our
>> current settings for astyle don't make a very good job of styling
>> switch/case code statements/blocks.
>> I propose that we add --indent-switches and --indent-cases to the script.
>> Any objections?
>>
>> If there are no objections I'll do a series of pushes to the tree:
>> 1) Any changes needed from running current astyle script.
>> 2) The change to the astyle script.
>> 3) Any changes needed from running the tweaked astyle script (plus some
>> tidying up of some switch/case code blocks - e.g. where a case block is
>> on the same line as the case statement).
> I am not so happy with the current style myself, but I would suggest you
> simply drop an example of the current and the new style here, so that we have
> a clearer picture.
>
> Also, what does each of the options achieve? Links to external references are
> fine.
>
http://astyle.sourceforge.net/astyle.html#_indent-switches
http://astyle.sourceforge.net/astyle.html#_indent-cases

I'm hoping these two links will explain both the option and the new 
style but just in case (from mymoneyscheduled.cpp):
Old style:
   switch (m_occurrence) {
   case OCCUR_ONCE:
     if (start_date >= _startDate && start_date <= endDate)
       theDates.append(start_date);
     break;

   case OCCUR_DAILY:
     while (date.isValid() && (date <= endDate)) {
       if (date >= _startDate)
         theDates.append(date);
       paymentDate = paymentDate.addDays(m_occurrenceMultiplier);
       date = adjustedDate(paymentDate, option);
     }
     break;

   case OCCUR_WEEKLY: {
     int step = 7 * m_occurrenceMultiplier;
     while (date.isValid() && (date <= endDate)) {
       if (date >= _startDate)
         theDates.append(date);
       paymentDate = paymentDate.addDays(step);
       date = adjustedDate(paymentDate, option);
     }
   }
   break;

New style:
   switch (m_occurrence) {
     case OCCUR_ONCE:
       if (start_date >= _startDate && start_date <= endDate)
         theDates.append(start_date);
       break;

     case OCCUR_DAILY:
       while (date.isValid() && (date <= endDate)) {
         if (date >= _startDate)
           theDates.append(date);
         paymentDate = paymentDate.addDays(m_occurrenceMultiplier);
         date = adjustedDate(paymentDate, option);
       }
       break;

     case OCCUR_WEEKLY: {
         int step = 7 * m_occurrenceMultiplier;
         while (date.isValid() && (date <= endDate)) {
           if (date >= _startDate)
             theDates.append(date);
           paymentDate = paymentDate.addDays(step);
           date = adjustedDate(paymentDate, option);
         }
       }
       break;

Regards,

Ian




More information about the KMyMoney-devel mailing list