Rockbox Development > Starting Development and Compiling
Patching Rockbox
Nate!:
Rincewind: First, I do not know C.  But, I'm looking at the scroll-margins patch.  I apply the patch and it fails  when making changes to onplay.c.  Do I contrast the rej file to the onplay.c.orig or to the onplay.c file?  I'm thinking the onplay.c.orig is the file before the patch was applied.  Maybe I need to contrast all the files: onplay.c, onplay.c.orig, onplay.c.rej, and the patch file.
*** Edit ***
Looking at both the onplay.c and onplay.c.orig there's an ifdef statement:
--- Quote ---#ifdef HAVE_LCD_BITMAP
    FOR_NB_SCREENS(i)
      screens.update();
#endif
--- End quote ---
In the patch there's this:
--- Quote --- #ifdef HAVE_LCD_BITMAP
    if (global_settings.statusbar)
- Â Â Â Â Â Â lcd_setmargins(0, STATUSBAR_HEIGHT);
+ Â Â Â Â Â Â lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
    else
- Â Â Â Â Â Â lcd_setmargins(0, 0);
+ Â Â Â Â Â Â lcd_setmargins(0, LCD_WIDTH, 0);
#endif
  }
--- End quote ---
In the rej file there's:
--- Quote --- Â #ifdef HAVE_LCD_BITMAP
     if (global_settings.statusbar)
+ Â Â Â Â Â Â lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
     else
+ Â Â Â Â Â Â lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
--- End quote ---
It seems that an endif is missing. (if (global_settings.statusbar), else, missing endif? Â If this is the case, where do I put the if, else, endif statement? Â Before the
--- Quote ---FOR_NB_SCREENS(i)
--- End quote ---
or after? Â Or am I completely off?
*** End Edit ***
This is good stuff, thanks for breaking it down.
Rincewind:
No, there is not an endif missing. In more detail: the surrounding "#ifdef" and "#endif" is so called preprocessor code, which is executed during compiling. The inside "if" statement is the C code. In C there is no "end". Instead curly braces are used "{" "}". Because there is only one statement in the if-else block, lazy coders can leave the braces out.
anyway, since the patch changes onplay.c and this file was changed fundamentally lately (the menus were converted to the new menu API) it is likely that the error is not easily corrected in this case.
If the patch is still maintained, then a new version should be added to flyspray soon.
bluebrother:
--- Quote from: Rincewind on May 03, 2007, 04:06:41 PM ---Because there is only one statement in the if-else block, lazy coders can leave the braces out.
--- End quote ---
Which is also considered as good style ... or as bad style, depending on who you ask. C leaves some options to the developer, and some styles are agreed being good, others are agreed being bad but most style decisions depend on the developer / project style guidelines if they are considered good or bad.
So I disagree in calling that "lazy" :D (you can also put multiple statements on one line using the comma operator for example, but this is rarely used)
Nate!:
Thanks for the responses. Oh well, thought I was on to something. ::)
Navigation
[0] Message Index
[*] Previous page
Go to full version