Ticket #10687: 0001-setarch-Inverse-arch-messages.patch

File 0001-setarch-Inverse-arch-messages.patch, 1.1 KB (added by puckipedia, 6 years ago)

Switch it up! (Apply after the other!)

  • src/bin/setarch.cpp

    From ba2d08ccc7c7da25933ac08ca0a2d68fa90514e7 Mon Sep 17 00:00:00 2001
    From: Puck Meerburg <puck@puckipedia.nl>
    Date: Mon, 17 Mar 2014 22:20:14 +0000
    Subject: [PATCH] setarch: Inverse arch messages
    
    ---
     src/bin/setarch.cpp | 19 +++++++++++++++++--
     1 file changed, 17 insertions(+), 2 deletions(-)
    
    diff --git a/src/bin/setarch.cpp b/src/bin/setarch.cpp
    index 9abc9ae..49752cc 100644
    a b main(int argc, const char* const* argv)  
    223223    if (!noPS1Set) {
    224224        BString ps1(getenv("PS1"));
    225225        BString arch_str;
    226         arch_str << "[" << architecture << "] ";
    227         ps1.Prepend(arch_str);
     226        arch_str << " [" << architecture << "]";
     227
     228        int archPosition = B_ERROR;
     229        int archLength = 0;
     230
     231        for (int i = 0; i < architectures.CountStrings(); i++) {
     232            int position = ps1.FindLast(architectures.StringAt(i));
     233            if (position > archPosition) {
     234                archPosition = position;
     235                archLength = architectures.StringAt(i).Length();
     236            }
     237        }
     238
     239        archPosition += archLength;
     240        archPosition += 1;
     241   
     242        ps1.Insert(arch_str, archPosition);
    228243
    229244        // set PS1
    230245        if (setenv("PS1", ps1, 1) != 0) {