Yes, I see what you mean! Though it looks to me as if most of those loops fit reasonably well into a for statement, with the only annoying part being the need to declare some variables up front. I don't know what XEmacs's portability requirements are, but if they include C89 then you might find that my trickery doesn't benefit you after all due to the one extra-C89 feature (bringing declarations into scope via for initialisers) not being available to you.
forinitialisers) not being available to you.