Re: [PHP] CamelCase conversion to proper_c_style

2009-04-27 Thread Richard Heyes
Hi,

 I know it's probably heresy for a lot of coders, but does anyone know a
 function or class or regexp or somesuch which will scan through a PHP
 file and convert all the CamelCase code into proper C-type code? That
 is, CamelCase gets converted to camel_case. I snagged a bunch of
 someone else's PHP code I'd like to modify, but it's coded the wrong
 way, so I'd like to fix it.

 (I'm teasing you CamelCase people. But I really would like to change
 this code around, because it doesn't happen to be my preference.)

I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] CamelCase conversion to proper_c_style

2009-04-27 Thread Marc Christopher Hall
My suggestion is to use the Find and Replace feature of your code editing
software. Sorry to disagree with Mr. Hayes, however, if you do as he says
and replace as you go you will be creating errors as these variables,
functions, etc will most likely be CaSe SenSItiVe. Change one then you need
to change all. 

As always, do not forget the first three rules of code writing; backup,
backup, backup.

Marc Hall

The difference between genius and stupidity is that genius has its limits.


*
Hi,

 I know it's probably heresy for a lot of coders, but does anyone know a
 function or class or regexp or somesuch which will scan through a PHP
 file and convert all the CamelCase code into proper C-type code? That
 is, CamelCase gets converted to camel_case. I snagged a bunch of
 someone else's PHP code I'd like to modify, but it's coded the wrong
 way, so I'd like to fix it.

 (I'm teasing you CamelCase people. But I really would like to change
 this code around, because it doesn't happen to be my preference.)

I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


__ Information from ESET Smart Security, version of virus signature
database 4036 (20090427) __

The message was checked by ESET Smart Security.

http://www.eset.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CamelCase conversion to proper_c_style

2009-04-27 Thread tedd

At 9:40 AM +0100 4/27/09, Richard Heyes wrote:

Hi,


 I know it's probably heresy for a lot of coders, but does anyone know a
 function or class or regexp or somesuch which will scan through a PHP
 file and convert all the CamelCase code into proper C-type code? That
 is, CamelCase gets converted to camel_case. I snagged a bunch of
 someone else's PHP code I'd like to modify, but it's coded the wrong
 way, so I'd like to fix it.

 (I'm teasing you CamelCase people. But I really would like to change
 this code around, because it doesn't happen to be my preference.)


I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.

--
Richard Heyes



Not only that. but it you leave each function alone until you work on 
it, then you'll have at least some indication of where/when an error 
has been introduced.


Many time when I'm using a piece of code that isn't formatted as I 
like, I first get it to work as I want changing only the functions 
that I must change. After everything is working, I then step through 
the code, reformat, and change in small steps.


HTH's

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CamelCase conversion to proper_c_style

2009-04-27 Thread Nathan Rixham

tedd wrote:

At 9:40 AM +0100 4/27/09, Richard Heyes wrote:

Hi,


 I know it's probably heresy for a lot of coders, but does anyone know a
 function or class or regexp or somesuch which will scan through a PHP
 file and convert all the CamelCase code into proper C-type code? That
 is, CamelCase gets converted to camel_case. I snagged a bunch of
 someone else's PHP code I'd like to modify, but it's coded the wrong
 way, so I'd like to fix it.

 (I'm teasing you CamelCase people. But I really would like to change
 this code around, because it doesn't happen to be my preference.)


I'd say, if you must, then change as you go. If you do it all in a
oner you'll likely introduce a shed load of problems.

--
Richard Heyes



Not only that. but it you leave each function alone until you work on 
it, then you'll have at least some indication of where/when an error has 
been introduced.


Many time when I'm using a piece of code that isn't formatted as I like, 
I first get it to work as I want changing only the functions that I must 
change. After everything is working, I then step through the code, 
reformat, and change in small steps.


HTH's

tedd



whereas I'd say it shouldn't be a problem to do automatically (but will 
be); just only use a tokenizer and not any form of regex or str_replace 
etc, that way you can be sure you are ONLY changing classes, methods, 
functions, function calls, variables etc


you still may have some problems with any call_user_func or string 
references though!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CamelCase conversion to proper_c_style

2009-04-27 Thread Daniel Brown
On Mon, Apr 27, 2009 at 01:25, Paul M Foster pa...@quillandmouse.com wrote:
 I know it's probably heresy for a lot of coders, but does anyone know a
 function or class or regexp or somesuch which will scan through a PHP
 file and convert all the CamelCase code into proper C-type code? That
 is, CamelCase gets converted to camel_case. I snagged a bunch of
 someone else's PHP code I'd like to modify, but it's coded the wrong
 way, so I'd like to fix it.

The other suggestions are more appropriate, of course, but in
direct response to your question, something like this would work
(though I'm typing it in here and it hasn't been tested):

#!/bin/bash
if(test `which vim` == ); then
vi=`which vi`;
else
vi=`which vim`;
fi;
$vi `grep -lRi \$[a-z0-9] *` '+%s/\$\([a-zA-Z0-9_]\)\+/\L\E/g' '+wn' '+q'

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php