Re: [PATCH v3 1/4] btrfs-progs: utils: Introduce function to escape characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





At 11/02/2016 06:55 PM, David Sterba wrote:
On Wed, Nov 02, 2016 at 09:19:10AM +0800, Qu Wenruo wrote:


At 11/01/2016 06:08 PM, David Sterba wrote:
On Tue, Nov 01, 2016 at 04:01:43PM +0800, Qu Wenruo wrote:
Introduce new function, escape_string_inplace(), to escape specified
characters in place.

Sorry, the pointer to seq_path was misleading. The actual escape
function is mangle_path and it copies one string to another. As we just
print the path, we can simply switch and call putchar.


Putchar() method is indeed much easier to implement.

But it makes us hard to do further formatting, like aligning the path to
given width. (At least we are still using 32 chars alignment for path)

So I still prefer the current full function string escaping and still
use %-32s for formatting.


And the idea of implementing escape_string_inplace() as a pure string
manipulation function can make it more agile for later use.
For example, we can reuse it for print-tree.

Reusing is fine, but I really don't like that the function modifies the
argument. What if the function is called twice on the same string?
Forgot to ask, what's the problem calling the function twice on the same string?

escape_string_inplace(dest, " ");
escape_string_inplace(dest, "\n");

is just the same as

escape_string_inplace(dest, " \n");

So I see no problem here.

Thanks,
Qu


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux